|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :GoogleKeywordInsightService.php
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/25 11:36
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :google关键字扩展
|
|
|
|
* @name :GoogleKeywordInsightService
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/25 11:38
|
|
|
|
*/
|
|
|
|
class GoogleKeywordInsightService
|
|
|
|
{
|
|
|
|
public $url = "https://google-keyword-insight1.p.rapidapi.com/globalkey";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :请求数据
|
|
|
|
* @name :requestUrl
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/25 11:36
|
|
|
|
*/
|
|
|
|
public function requestUrl($keyword){
|
|
|
|
$url = $this->url.'/?keyword='.$keyword.'&lang=en';
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, [
|
|
|
|
CURLOPT_URL => $url,
|
|
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
|
|
CURLOPT_ENCODING => "",
|
|
|
|
CURLOPT_MAXREDIRS => 10,
|
|
|
|
CURLOPT_TIMEOUT => 30,
|
|
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
|
|
CURLOPT_CUSTOMREQUEST => "GET",
|
|
|
|
CURLOPT_HTTPHEADER => [
|
|
|
|
"x-rapidapi-host: google-keyword-insight1.p.rapidapi.com",
|
|
|
|
"x-rapidapi-key: d246239565mshc29088b58ff484dp17c0bdjsn2d28d03622c7"
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
$err = curl_error($curl);
|
|
|
|
curl_close($curl);
|
|
|
|
if ($err) {
|
|
|
|
return "cURL Error #:" . $err;
|
|
|
|
} else {
|
|
|
|
return json_decode($response,true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|