作者 lyh

gx

... ... @@ -973,5 +973,261 @@ class Country
]
}';
/**
* @remark :国家码与国家名称的映射
* @name :getCountryNameByAlpha3
* @author :lyh
* @method :post
* @time :2025/3/27 10:38
*/
public function getCountryNameByAlpha3($alpha3) {
// ISO 3166-1 alpha-3 国家码与国家名称的映射
$countries = [
'AFG' => 'Afghanistan',
'ALB' => 'Albania',
'DZA' => 'Algeria',
'AND' => 'Andorra',
'AGO' => 'Angola',
'ATG' => 'Antigua and Barbuda',
'ARG' => 'Argentina',
'ARM' => 'Armenia',
'AUS' => 'Australia',
'AUT' => 'Austria',
'AZE' => 'Azerbaijan',
'BHS' => 'Bahamas',
'BHR' => 'Bahrain',
'BGD' => 'Bangladesh',
'BRB' => 'Barbados',
'BLR' => 'Belarus',
'BEL' => 'Belgium',
'BLZ' => 'Belize',
'BEN' => 'Benin',
'BTN' => 'Bhutan',
'BOL' => 'Bolivia',
'BES' => 'Bonaire, Sint Eustatius and Saba',
'BIH' => 'Bosnia and Herzegovina',
'BWA' => 'Botswana',
'BVT' => 'Bouvet Island',
'BRA' => 'Brazil',
'IOT' => 'British Indian Ocean Territory',
'BRN' => 'Brunei Darussalam',
'BGR' => 'Bulgaria',
'BFA' => 'Burkina Faso',
'BDI' => 'Burundi',
'CPV' => 'Cabo Verde',
'KHM' => 'Cambodia',
'CMR' => 'Cameroon',
'CAN' => 'Canada',
'CYM' => 'Cayman Islands',
'CAF' => 'Central African Republic',
'TCD' => 'Chad',
'CHL' => 'Chile',
'CHN' => 'China',
'CXR' => 'Christmas Island',
'CCK' => 'Cocos (Keeling) Islands',
'COL' => 'Colombia',
'COM' => 'Comoros',
'COD' => 'Congo (Democratic Republic of the)',
'COG' => 'Congo',
'COK' => 'Cook Islands',
'CRI' => 'Costa Rica',
'CIV' => 'Côte d\'Ivoire',
'HRV' => 'Croatia',
'CUB' => 'Cuba',
'CUW' => 'Curaçao',
'CYP' => 'Cyprus',
'CZE' => 'Czech Republic',
'DNK' => 'Denmark',
'DJI' => 'Djibouti',
'DMA' => 'Dominica',
'DOM' => 'Dominican Republic',
'ECU' => 'Ecuador',
'EGY' => 'Egypt',
'SLV' => 'El Salvador',
'GNQ' => 'Equatorial Guinea',
'ERI' => 'Eritrea',
'EST' => 'Estonia',
'SWZ' => 'Eswatini',
'ETH' => 'Ethiopia',
'FLK' => 'Falkland Islands (Malvinas)',
'FRO' => 'Faroe Islands',
'FJI' => 'Fiji',
'FIN' => 'Finland',
'FRA' => 'France',
'GUF' => 'French Guiana',
'PYF' => 'French Polynesia',
'ATF' => 'French Southern Territories',
'GAB' => 'Gabon',
'GMB' => 'Gambia',
'GEO' => 'Georgia',
'DEU' => 'Germany',
'GHA' => 'Ghana',
'GIB' => 'Gibraltar',
'GRC' => 'Greece',
'GRL' => 'Greenland',
'GRD' => 'Grenada',
'GLP' => 'Guadeloupe',
'GUM' => 'Guam',
'GTM' => 'Guatemala',
'GGY' => 'Guernsey',
'GIN' => 'Guinea',
'GNB' => 'Guinea-Bissau',
'GUY' => 'Guyana',
'HTI' => 'Haiti',
'HMD' => 'Heard Island and McDonald Islands',
'VAT' => 'Holy See',
'HND' => 'Honduras',
'HKG' => 'Hong Kong',
'HUN' => 'Hungary',
'ISL' => 'Iceland',
'IND' => 'India',
'IDN' => 'Indonesia',
'IRN' => 'Iran (Islamic Republic of)',
'IRQ' => 'Iraq',
'IRL' => 'Ireland',
'IMN' => 'Isle of Man',
'ISR' => 'Israel',
'ITA' => 'Italy',
'JAM' => 'Jamaica',
'JPN' => 'Japan',
'JEY' => 'Jersey',
'JOR' => 'Jordan',
'KAZ' => 'Kazakhstan',
'KEN' => 'Kenya',
'KIR' => 'Kiribati',
'KOR' => 'Korea (Republic of)',
'KWT' => 'Kuwait',
'KGZ' => 'Kyrgyzstan',
'LAO' => 'Lao People\'s Democratic Republic',
'LVA' => 'Latvia',
'LBN' => 'Lebanon',
'LSO' => 'Lesotho',
'LBR' => 'Liberia',
'LBY' => 'Libya',
'LIE' => 'Liechtenstein',
'LTU' => 'Lithuania',
'LUX' => 'Luxembourg',
'MAC' => 'Macao',
'MDG' => 'Madagascar',
'MWI' => 'Malawi',
'MYS' => 'Malaysia',
'MDV' => 'Maldives',
'MLI' => 'Mali',
'MLT' => 'Malta',
'MHL' => 'Marshall Islands',
'MTQ' => 'Martinique',
'MRT' => 'Mauritania',
'MUS' => 'Mauritius',
'MYT' => 'Mayotte',
'MEX' => 'Mexico',
'FSM' => 'Micronesia (Federated States of)',
'MDA' => 'Moldova (Republic of)',
'MCO' => 'Monaco',
'MNG' => 'Mongolia',
'MNE' => 'Montenegro',
'MSR' => 'Montserrat',
'MAR' => 'Morocco',
'MOZ' => 'Mozambique',
'MMR' => 'Myanmar',
'NAM' => 'Namibia',
'NRU' => 'Nauru',
'NPL' => 'Nepal',
'NLD' => 'Netherlands',
'NCL' => 'New Caledonia',
'NZL' => 'New Zealand',
'NIC' => 'Nicaragua',
'NER' => 'Niger',
'NGA' => 'Nigeria',
'NIU' => 'Niue',
'NFK' => 'Norfolk Island',
'MNP' => 'Northern Mariana Islands',
'NOR' => 'Norway',
'OMN' => 'Oman',
'PAK' => 'Pakistan',
'PLW' => 'Palau',
'PSE' => 'Palestine, State of',
'PAN' => 'Panama',
'PNG' => 'Papua New Guinea',
'PRY' => 'Paraguay',
'PER' => 'Peru',
'PHL' => 'Philippines',
'PCN' => 'Pitcairn',
'POL' => 'Poland',
'PRT' => 'Portugal',
'PRI' => 'Puerto Rico',
'QAT' => 'Qatar',
'REU' => 'Réunion',
'ROU' => 'Romania',
'RUS' => 'Russian Federation',
'RWA' => 'Rwanda',
'BLM' => 'Saint Barthélemy',
'SHN' => 'Saint Helena, Ascension and Tristan da Cunha',
'KNA' => 'Saint Kitts and Nevis',
'LCA' => 'Saint Lucia',
'MAF' => 'Saint Martin (French part)',
'SPM' => 'Saint Pierre and Miquelon',
'VCT' => 'Saint Vincent and the Grenadines',
'WSM' => 'Samoa',
'SMR' => 'San Marino',
'STP' => 'Sao Tome and Principe',
'SAU' => 'Saudi Arabia',
'SEN' => 'Senegal',
'SRB' => 'Serbia',
'SYC' => 'Seychelles',
'SLE' => 'Sierra Leone',
'SGP' => 'Singapore',
'SXM' => 'Sint Maarten (Dutch part)',
'SVK' => 'Slovakia',
'SVN' => 'Slovenia',
'SLB' => 'Solomon Islands',
'SOM' => 'Somalia',
'ZAF' => 'South Africa',
'SGS' => 'South Georgia and the South Sandwich Islands',
'SSD' => 'South Sudan',
'ESP' => 'Spain',
'LKA' => 'Sri Lanka',
'SDN' => 'Sudan',
'SUR' => 'Suriname',
'SJM' => 'Svalbard and Jan Mayen',
'SWE' => 'Sweden',
'CHE' => 'Switzerland',
'SYR' => 'Syrian Arab Republic',
'TWN' => 'Taiwan, Province of China',
'TJK' => 'Tajikistan',
'TZA' => 'Tanzania, United Republic of',
'THA' => 'Thailand',
'TLS' => 'Timor-Leste',
'TGO' => 'Togo',
'TKL' => 'Tokelau',
'TON' => 'Tonga',
'TTO' => 'Trinidad and Tobago',
'TUN' => 'Tunisia',
'TUR' => 'Turkey',
'TKM' => 'Turkmenistan',
'TCA' => 'Turks and Caicos Islands',
'TUV' => 'Tuvalu',
'UGA' => 'Uganda',
'UKR' => 'Ukraine',
'ARE' => 'United Arab Emirates',
'GBR' => 'United Kingdom',
'USA' => 'United States',
'URY' => 'Uruguay',
'UZB' => 'Uzbekistan',
'VUT' => 'Vanuatu',
'VEN' => 'Venezuela (Bolivarian Republic of)',
'VNM' => 'Viet Nam',
'WLF' => 'Wallis and Futuna',
'ESH' => 'Western Sahara',
'YEM' => 'Yemen',
'ZMB' => 'Zambia',
'ZWE' => 'Zimbabwe',
];
// 检查国家码是否存在于数组中
if (array_key_exists($alpha3, $countries)) {
return $countries[$alpha3];
} else {
return false;
}
}
}
... ...
... ... @@ -119,7 +119,7 @@ if (!function_exists('http_get')) {
$access_txt = curl_exec($ch1);
if (curl_errno($ch1)) {
$error_message = curl_error($ch1);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($error_message, true) . PHP_EOL, FILE_APPEND);
errorLog('请求失败', $url, $error_message);
}
curl_close($ch1);
return json_decode($access_txt, true);
... ...
... ... @@ -28,7 +28,7 @@ use App\Models\Project\Project;
use App\Models\Project\ProjectAiSetting;
use App\Models\RouteMap\RouteMap;
use App\Services\AiBlogService;
use App\Services\GoogleKeywordInsightService;
use App\Services\GoogleSearchService;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
... ...
... ... @@ -13,7 +13,7 @@ use App\Helper\Translate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\GoogleKeywordInsight\GoogleKeywordInsight;
use App\Models\GoogleKeywordInsight\GoogleKeywordInsightDetail;
use App\Services\GoogleKeywordInsightService;
use App\Services\GoogleSearchService;
use Illuminate\Support\Facades\DB;
class GoogleKeywordInsightLogic extends BaseLogic
... ... @@ -37,7 +37,7 @@ class GoogleKeywordInsightLogic extends BaseLogic
public function getGoogleInsight(){
$data = $this->model->read(['search'=>$this->param['keyword']]);
if($data === false){
$this->service = new GoogleKeywordInsightService();
$this->service = new GoogleSearchService();
$data = $this->service->requestUrl($this->param['keyword']);
if(!empty($data)){
DB::beginTransaction();
... ... @@ -52,6 +52,9 @@ class GoogleKeywordInsightLogic extends BaseLogic
$this->fail('保存失败,请联系管理员');
}
}
}else{
$googleDetailModel = new GoogleKeywordInsightDetail();
$data = $googleDetailModel->list(['search'=>$this->param['keyword']]);
}
return $this->success($data);
}
... ...
<?php
/**
* @remark :
* @name :GoogleKeywordInsightService.php
* @name :GoogleSearchService.php
* @author :lyh
* @method :post
* @time :2025/3/25 11:36
... ... @@ -11,12 +11,12 @@ namespace App\Services;
/**
* @remark :google关键字扩展
* @name :GoogleKeywordInsightService
* @name :GoogleSearchService
* @author :lyh
* @method :post
* @time :2025/3/25 11:38
*/
class GoogleKeywordInsightService
class GoogleSearchService
{
public $url = "";
... ... @@ -54,4 +54,19 @@ class GoogleKeywordInsightService
return json_decode($response,true);
}
}
/**
* @remark :google搜索
* @name :googleSearch
* @author :lyh
* @method :post
* @time :2025/3/27 11:18
* @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;
return http_get($url);
}
}
... ...