|
...
|
...
|
@@ -23,7 +23,7 @@ class GoogleSearchService |
|
|
|
public $url = "";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :请求数据
|
|
|
|
* @remark :扩展关键词请求数据
|
|
|
|
* @name :requestUrl
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
...
|
...
|
@@ -32,6 +32,30 @@ class GoogleSearchService |
|
|
|
public function requestUrl($keyword){
|
|
|
|
$this->url = 'https://google-keyword-insight1.p.rapidapi.com/globalkey';
|
|
|
|
$url = $this->url.'/?keyword='.$keyword.'&lang=en';
|
|
|
|
return $this->curlGoogleApi($url);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :热门关键词拉取
|
|
|
|
* @name :requestKeywordUrl
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/27 16:57
|
|
|
|
*/
|
|
|
|
public function requestKeywordUrl($keyword){
|
|
|
|
$this->url = 'https://google-keyword-insight1.p.rapidapi.com/topkeys';
|
|
|
|
$url = $this->url.'/?keyword='.$keyword.'&location=US&&lang=en';
|
|
|
|
return $this->curlGoogleApi($url);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :请求
|
|
|
|
* @name :curlGoogleApi
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/27 16:59
|
|
|
|
*/
|
|
|
|
public function curlGoogleApi($url){
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, [
|
|
|
|
CURLOPT_URL => $url,
|
|
...
|
...
|
@@ -50,15 +74,13 @@ class GoogleSearchService |
|
|
|
$err = curl_error($curl);
|
|
|
|
curl_close($curl);
|
|
|
|
if ($err) {
|
|
|
|
errorLog("关键词扩展cURL Error #:", $url, $err);
|
|
|
|
errorLog("热门关键词cURL Error #:", $url, $err);
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return json_decode($response,true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :google搜索
|
|
|
|
* @name :googleSearch
|
...
|
...
|
|