作者 李宇航

合并分支 'lyh-server' 到 'master'

gx



查看合并请求 !1558
... ... @@ -118,6 +118,8 @@ class AiBlogLogic extends BaseLogic
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]);
$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)
]);
}else{
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($result, true) . PHP_EOL, FILE_APPEND);
}
return $this->success();
}
... ...
<?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);
}
}
}
... ...