正在显示
2 个修改的文件
包含
57 行增加
和
0 行删除
| @@ -118,6 +118,8 @@ class AiBlogLogic extends BaseLogic | @@ -118,6 +118,8 @@ class AiBlogLogic extends BaseLogic | ||
| 118 | $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]); | 118 | $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]); |
| 119 | $this->model->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>1, 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],'anchor'=>json_encode($this->param['anchor'] ?? [],true) | 119 | $this->model->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>1, 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],'anchor'=>json_encode($this->param['anchor'] ?? [],true) |
| 120 | ]); | 120 | ]); |
| 121 | + }else{ | ||
| 122 | + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($result, true) . PHP_EOL, FILE_APPEND); | ||
| 121 | } | 123 | } |
| 122 | return $this->success(); | 124 | return $this->success(); |
| 123 | } | 125 | } |
app/Services/GoogleKeywordInsightService.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :GoogleKeywordInsightService.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/3/25 11:36 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Services; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * @remark :google关键字扩展 | ||
| 14 | + * @name :GoogleKeywordInsightService | ||
| 15 | + * @author :lyh | ||
| 16 | + * @method :post | ||
| 17 | + * @time :2025/3/25 11:38 | ||
| 18 | + */ | ||
| 19 | +class GoogleKeywordInsightService | ||
| 20 | +{ | ||
| 21 | + public $url = "https://google-keyword-insight1.p.rapidapi.com/globalkey"; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * @remark :请求数据 | ||
| 25 | + * @name :requestUrl | ||
| 26 | + * @author :lyh | ||
| 27 | + * @method :post | ||
| 28 | + * @time :2025/3/25 11:36 | ||
| 29 | + */ | ||
| 30 | + public function requestUrl($keyword){ | ||
| 31 | + $url = $this->url.'/?keyword='.$keyword.'&lang=en'; | ||
| 32 | + $curl = curl_init(); | ||
| 33 | + curl_setopt_array($curl, [ | ||
| 34 | + CURLOPT_URL => $url, | ||
| 35 | + CURLOPT_RETURNTRANSFER => true, | ||
| 36 | + CURLOPT_ENCODING => "", | ||
| 37 | + CURLOPT_MAXREDIRS => 10, | ||
| 38 | + CURLOPT_TIMEOUT => 30, | ||
| 39 | + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | ||
| 40 | + CURLOPT_CUSTOMREQUEST => "GET", | ||
| 41 | + CURLOPT_HTTPHEADER => [ | ||
| 42 | + "x-rapidapi-host: google-keyword-insight1.p.rapidapi.com", | ||
| 43 | + "x-rapidapi-key: d246239565mshc29088b58ff484dp17c0bdjsn2d28d03622c7" | ||
| 44 | + ], | ||
| 45 | + ]); | ||
| 46 | + $response = curl_exec($curl); | ||
| 47 | + $err = curl_error($curl); | ||
| 48 | + curl_close($curl); | ||
| 49 | + if ($err) { | ||
| 50 | + return "cURL Error #:" . $err; | ||
| 51 | + } else { | ||
| 52 | + return json_decode($response,true); | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | +} |
-
请 注册 或 登录 后发表评论