作者 lyh

gx

<?php
/**
* @remark :
* @name :GoogleSearchController.php
* @author :lyh
* @method :post
* @time :2025/3/27 13:53
*/
namespace App\Http\Controllers\Bside\GoogleKeywordInsight;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Services\GoogleSearchService;
class GoogleSearchController extends BaseController
{
/**
* @remark :google搜索数据
* @name :searchList
* @author :lyh
* @method :post
* @time :2025/3/27 13:59
*/
public function searchList(){
$this->request->validate([
'search' => 'required'
],[
'search.required' => '搜索类型不能为空',
]);
//获取当前项目域名
$domain = parse_url($this->user['domain'], PHP_URL_HOST);
$googleService = new GoogleSearchService();
$googleService->googleSearch();
$data = [];
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -55,17 +55,26 @@ class GoogleSearchService
}
}
/**
* @remark :google搜索
* @name :googleSearch
* @author :lyh
* @method :post
* @time :2025/3/27 11:18
* @param :date,query,page,device,country
* @param :date,query,page,device,country/时间、聚合、前页、设备、国家
*/
public function googleSearch($data){
$this->url = 'https://www.cmer.site/api/google/search?domain=www.suertetextile.com&q=';
$url = $this->url.$data;
public function googleSearch($domain,$search){
$data = [
1=>'date',
2=>'query',
3=>'page',
4=>'device',
5=>'country'
];
$this->url = 'https://www.cmer.site/api/google/search';
$url = $this->url.'?domain='.$domain.'&q='.$data[$search];
return http_get($url);
}
... ...