正在显示
1 个修改的文件
包含
26 行增加
和
4 行删除
| @@ -23,7 +23,7 @@ class GoogleSearchService | @@ -23,7 +23,7 @@ class GoogleSearchService | ||
| 23 | public $url = ""; | 23 | public $url = ""; |
| 24 | 24 | ||
| 25 | /** | 25 | /** |
| 26 | - * @remark :请求数据 | 26 | + * @remark :扩展关键词请求数据 |
| 27 | * @name :requestUrl | 27 | * @name :requestUrl |
| 28 | * @author :lyh | 28 | * @author :lyh |
| 29 | * @method :post | 29 | * @method :post |
| @@ -32,6 +32,30 @@ class GoogleSearchService | @@ -32,6 +32,30 @@ class GoogleSearchService | ||
| 32 | public function requestUrl($keyword){ | 32 | public function requestUrl($keyword){ |
| 33 | $this->url = 'https://google-keyword-insight1.p.rapidapi.com/globalkey'; | 33 | $this->url = 'https://google-keyword-insight1.p.rapidapi.com/globalkey'; |
| 34 | $url = $this->url.'/?keyword='.$keyword.'&lang=en'; | 34 | $url = $this->url.'/?keyword='.$keyword.'&lang=en'; |
| 35 | + return $this->curlGoogleApi($url); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * @remark :热门关键词拉取 | ||
| 40 | + * @name :requestKeywordUrl | ||
| 41 | + * @author :lyh | ||
| 42 | + * @method :post | ||
| 43 | + * @time :2025/3/27 16:57 | ||
| 44 | + */ | ||
| 45 | + public function requestKeywordUrl($keyword){ | ||
| 46 | + $this->url = 'https://google-keyword-insight1.p.rapidapi.com/topkeys'; | ||
| 47 | + $url = $this->url.'/?keyword='.$keyword.'&location=US&&lang=en'; | ||
| 48 | + return $this->curlGoogleApi($url); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * @remark :请求 | ||
| 53 | + * @name :curlGoogleApi | ||
| 54 | + * @author :lyh | ||
| 55 | + * @method :post | ||
| 56 | + * @time :2025/3/27 16:59 | ||
| 57 | + */ | ||
| 58 | + public function curlGoogleApi($url){ | ||
| 35 | $curl = curl_init(); | 59 | $curl = curl_init(); |
| 36 | curl_setopt_array($curl, [ | 60 | curl_setopt_array($curl, [ |
| 37 | CURLOPT_URL => $url, | 61 | CURLOPT_URL => $url, |
| @@ -50,15 +74,13 @@ class GoogleSearchService | @@ -50,15 +74,13 @@ class GoogleSearchService | ||
| 50 | $err = curl_error($curl); | 74 | $err = curl_error($curl); |
| 51 | curl_close($curl); | 75 | curl_close($curl); |
| 52 | if ($err) { | 76 | if ($err) { |
| 53 | - errorLog("关键词扩展cURL Error #:", $url, $err); | 77 | + errorLog("热门关键词cURL Error #:", $url, $err); |
| 54 | return false; | 78 | return false; |
| 55 | } else { | 79 | } else { |
| 56 | return json_decode($response,true); | 80 | return json_decode($response,true); |
| 57 | } | 81 | } |
| 58 | } | 82 | } |
| 59 | 83 | ||
| 60 | - | ||
| 61 | - | ||
| 62 | /** | 84 | /** |
| 63 | * @remark :google搜索 | 85 | * @remark :google搜索 |
| 64 | * @name :googleSearch | 86 | * @name :googleSearch |
-
请 注册 或 登录 后发表评论