作者 lyh

gx

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GoogleSearchController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/3/27 13:53
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\GoogleKeywordInsight;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Services\GoogleSearchService;
  15 +
  16 +class GoogleSearchController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :google搜索数据
  20 + * @name :searchList
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2025/3/27 13:59
  24 + */
  25 + public function searchList(){
  26 + $this->request->validate([
  27 + 'search' => 'required'
  28 + ],[
  29 + 'search.required' => '搜索类型不能为空',
  30 + ]);
  31 + //获取当前项目域名
  32 + $domain = parse_url($this->user['domain'], PHP_URL_HOST);
  33 + $googleService = new GoogleSearchService();
  34 + $googleService->googleSearch();
  35 + $data = [];
  36 + $this->response('success',Code::SUCCESS,$data);
  37 + }
  38 +}
@@ -55,17 +55,26 @@ class GoogleSearchService @@ -55,17 +55,26 @@ class GoogleSearchService
55 } 55 }
56 } 56 }
57 57
  58 +
  59 +
58 /** 60 /**
59 * @remark :google搜索 61 * @remark :google搜索
60 * @name :googleSearch 62 * @name :googleSearch
61 * @author :lyh 63 * @author :lyh
62 * @method :post 64 * @method :post
63 * @time :2025/3/27 11:18 65 * @time :2025/3/27 11:18
64 - * @param :date,query,page,device,country 66 + * @param :date,query,page,device,country/时间、聚合、前页、设备、国家
65 */ 67 */
66 - public function googleSearch($data){  
67 - $this->url = 'https://www.cmer.site/api/google/search?domain=www.suertetextile.com&q=';  
68 - $url = $this->url.$data; 68 + public function googleSearch($domain,$search){
  69 + $data = [
  70 + 1=>'date',
  71 + 2=>'query',
  72 + 3=>'page',
  73 + 4=>'device',
  74 + 5=>'country'
  75 + ];
  76 + $this->url = 'https://www.cmer.site/api/google/search';
  77 + $url = $this->url.'?domain='.$domain.'&q='.$data[$search];
69 return http_get($url); 78 return http_get($url);
70 } 79 }
71 80