| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466 | <?phpnamespace App\Http\Controllers\Admin;use App\Http\Models\Site;use App\Http\Models\WebmasterCountry;use App\Http\Models\WebmasterEffect;use App\Http\Models\WebmasterFlow;use App\Http\Models\WebmasterInclude;use App\Http\Models\WebmasterKeyword;use App\Http\Models\WebmasterKeywordInfo;use App\Http\Models\WebmasterLog;use GuzzleHttp\Client;use Illuminate\Http\Request;use App\Http\Controllers\Controller;use Google_Service_Webmasters_SearchAnalyticsQueryRequest;use Google_Client;use Google_Service_Webmasters;/** * 谷歌webmaster * Class WebmasterController * @package App\Http\Controllers\Admin */class WebmasterController extends Controller{    protected $_redirectUrl = 'http://test.yinqingli.com/admin/webmaster/data';//    protected $_redirectUrl = 'http://test.rank.yinqingli.cn/admincp/webmaster/api';    protected $_oAuthCredentialsFile = './auth.json';    public function getData(Request $request)    {        $oauth_credentials = $this->getOAuthCredentialsFile($this->_oAuthCredentialsFile);        if (!$oauth_credentials) dd('CredentialsFile not exists');        $httpClient = new Client(['verify' => false]);        $client = new Google_Client();        $client->setHttpClient($httpClient);        $client->setAuthConfig($oauth_credentials);        $client->addScope([Google_Service_Webmasters::WEBMASTERS]);        if ($request->input('code')) {            $token = $client->fetchAccessTokenWithAuthCode($request->input('code'));            dd($token);            $client->setAccessToken($token);            $service = new Google_Service_Webmasters($client);            $this->makeSearchConsoleData($service);            dd('success');        } else {            dd('google 授权授权失败');        }    }    /**     * 授权     * @throws \Google_Exception     */    public function oauth()    {        $oauth_credentials = $this->getOAuthCredentialsFile($this->_oAuthCredentialsFile);        if (!$oauth_credentials) dump('CredentialsFile not exists');        $httpClient = new Client([            'verify' => false        ]);        $client = new Google_Client();        $client->setHttpClient($httpClient);        $client->setAuthConfig($oauth_credentials);        $client->setRedirectUri($this->_redirectUrl);        $client->addScope([Google_Service_Webmasters::WEBMASTERS]);        $authUrl = $client->createAuthUrl();        return redirect($authUrl);//        header('Location: ' . $authUrl);//        exit;    }    protected function getOAuthCredentialsFile($file)    {        if (file_exists($file)) {            return $file;        }        return false;    }    protected $_webmasterStartTime;    /**     * 生成webmaster数据     * @param $service     */    public function makeSearchConsoleData($service)    {        ignore_user_abort(true);        set_time_limit(0);        $body = new Google_Service_Webmasters_SearchAnalyticsQueryRequest();        $ym = date('Ym', strtotime('-1 month'));//默认读取上个月的数据        $this->_webmasterStartTime = strtotime($ym . '01');        $sites = Site::query()->where([])->get();        foreach ($sites as $key => $item) {            if (empty($item['webmaster_domain'])) {                continue;            }            if (empty($item['report_day'])) {                continue;            }            if (!WebmasterFlow::query()->where(['flow_ym' => $ym, 'site_id' => $item->id])->exists()) {                $isFirst = 0;                if (!WebmasterFlow::query()->where(['site_id' => $item->id])->exists()) {                    $isFirst = 1;                }                $flow = WebmasterFlow::query()->create([ //提前记录此项目已生成webmaster数据                    'project_id' => $item['id'],                    'flow_ym' => $ym,                    'create_time' => time(),                    'webmaster_domain' => $item['webmaster_domain'],                    'status' => 1                ]);                $finalResult = 1;                $this->traffic($body, $item, $service, $finalResult, $isFirst);                $this->homepageKeywords($body, $item, $service, $finalResult, $isFirst);                $this->countryTraffic($body, $item, $service, $finalResult, $isFirst);                $this->includePage($body, $item, $service, $finalResult, $isFirst);                $flow->update(['status' => $finalResult]);            }        }    }    /**     * time 1号的时间戳     * @param $time     * @return false|int     */    public function getEndDate($time)    {        return date('Y-m-d', strtotime('+1 month -1 day', $time));    }    /**     * webmaster 效果     * @param Google_Service_Webmasters_SearchAnalyticsQueryRequest $body     * @param $project     * @param $service     * @param $finalResult     * @param $isFirst //是否是第一次     * @return mixed     */    public function traffic(Google_Service_Webmasters_SearchAnalyticsQueryRequest $body, $project, $service, &$finalResult, $isFirst)    {        $frequency = 1;        if ($isFirst) {            $frequency = 6; //如果是第一次查6次        }        for ($count = 0; $count < $frequency; $count++) {            $startTime = strtotime('-' . $count . ' month', $this->_webmasterStartTime);            $body->setDimensions(['date']);            $body->setStartDate(date('Y-m-d', $startTime));            $body->setEndDate($this->getEndDate($startTime));            try {                $results = $service->searchanalytics->query($project['webmaster_domain'], $body);            } catch (\Throwable $exception) {                $finalResult = 0;                //如果有发现查询错误直接终止                return WebmasterLog::query()->create([                    'project_id' => $project['id'],                    'domain' => $project['webmaster_domain'],                    'ym' => date('Ym', $startTime),                    'create_time' => time(),                    'method' => __METHOD__,                    'detail' => $exception->getMessage()                ]);            }            if (!empty($results->rows)) {                foreach ($results->rows as $item) {                    if (empty($item['keys'][0])) continue;                    WebmasterEffect::query()->create([                        'project_id' => $project['id'],                        'domain' => $project['webmaster_domain'],                        'date_key' => $item['keys'][0],                        'clicks' => $item['clicks'],                        'impressions' => $item['impressions'],                        'ctr' => $item['ctr'],                        'position' => $item['position'],                        'create_time' => time(),                        'ym' => date('Ym', $startTime)                    ]);                }            }        }    }    /**     * 整站关键词首页量=>排名小于10的 个数相加  query     * @param Google_Service_Webmasters_SearchAnalyticsQueryRequest $body     * @param $project     * @param $service     * @param $finalResult     * @param $isFirst     * @return mixed     */    public function homepageKeywords(Google_Service_Webmasters_SearchAnalyticsQueryRequest $body, $project, $service, &$finalResult, $isFirst)    {        $frequency = 1;        if ($isFirst) {            $frequency = 6; //如果是第一次查6次        }        for ($count = 0; $count < $frequency; $count++) {            $startTime = strtotime('-' . $count . ' month', $this->_webmasterStartTime);            $body->setStartDate(date('Y-m-d', $startTime));            $body->setEndDate($this->getEndDate($startTime));            $body->setDimensions(['query']);            try {                $results = $service->searchanalytics->query($project['webmaster_domain'], $body);            } catch (\Throwable $exception) {                $finalResult = 0;                return WebmasterLog::query()->create([                    'project_id' => $project['id'],                    'webmaster_domain' => $project['webmaster_domain'],                    'ym' => date('Ym', $startTime),                    'create_time' => time(),                    'method' => __METHOD__,                    'detail' => $exception->getMessage()                ]);            }            if (!empty($results->rows)) {                $total = 0;                foreach ($results->rows as $item) {                    if ($item['position'] < 10) {                        WebmasterKeywordInfo::query()->create([                            'domain' => $project['webmaster_domain'],                            'project_id' => $project['id'],                            'query' => $item['keys'][0] ? $item['keys'][0] : '',                            'clicks' => $item['clicks'],                            'impressions' => $item['impressions'],                            'ctr' => $item['ctr'],                            'position' => $item['position'],                            'ym' => date('Ym', $startTime),                            'create_time' => time()                        ]);                        $total++;                    }                }                WebmasterKeyword::query()->create([                    'project_id' => $project['id'],                    'ym' => date('Ym', $startTime),                    'domain' => $project['webmaster_domain'],                    'total' => $total,                    'create_time' => time()                ]);            }        }    }    /**     * webmaster 覆盖率 有效网页     * @param Google_Service_Webmasters_SearchAnalyticsQueryRequest $body     * @param $project     * @param $service     * @param $finalResult     * @param $isFirst     * @return mixed     */    public function includePage(Google_Service_Webmasters_SearchAnalyticsQueryRequest $body, $project, $service, &$finalResult, $isFirst)    {        $frequency = 1;        if ($isFirst) {            $frequency = 6; //如果是第一次查6次        }        for ($count = 0; $count < $frequency; $count++) {            $body->setDimensions(['page']);            $startTime = strtotime('-' . $count . ' month', $this->_webmasterStartTime);            $body->setStartDate(date('Y-m-d', $startTime));            $body->setEndDate($this->getEndDate($startTime));            try {                $results = $service->searchanalytics->query($project['webmaster_domain'], $body);            } catch (\Throwable $exception) {                $finalResult = 0;                return WebmasterLog::query()->create([                    'project_id' => $project['id'],                    'webmaster_domain' => $project['webmaster_domain'],                    'ym' => date('Ym', $startTime),                    'create_time' => time(),                    'method' => __METHOD__,                    'detail' => $exception->getMessage()                ]);            }            if (!empty($results->rows)) {                WebmasterInclude::query()->create([                    'project_id' => $project['id'],                    'domain' => $project['webmaster_domain'],                    'total' => count($results->rows),                    'create_time' => time(),                    'ym' => date('Ym', $startTime)                ]);            }        }    }    /**     * 国家地区分布     * @param Google_Service_Webmasters_SearchAnalyticsQueryRequest $body     * @param $project     * @param $service     * @param $finalResult     * @param $isFirst     * @return mixed     */    public function countryTraffic(Google_Service_Webmasters_SearchAnalyticsQueryRequest $body, $project, $service, &$finalResult, $isFirst)    {        $frequency = 1;        if ($isFirst) {            $frequency = 6; //如果是第一次查6次        }        for ($count = 0; $count < $frequency; $count++) {            $regions = $this->regions();            $body->setDimensions(['country']);            $startTime = strtotime('-' . $count . ' month', $this->_webmasterStartTime);            $body->setStartDate(date('Y-m-d', $startTime));            $body->setEndDate($this->getEndDate($startTime));            try {                $results = $service->searchanalytics->query($project['webmaster_domain'], $body);            } catch (\Throwable $exception) {                $finalResult = 0;                return WebmasterLog::query()->create([                    'project_id' => $project['id'],                    'webmaster_domain' => $project['webmaster_domain'],                    'ym' => date('Ym', $startTime),                    'create_time' => time(),                    'method' => __METHOD__,                    'detail' => $exception->getMessage()                ]);            }            if (!empty($results->rows)) {                $rows = $this->objectToArray($results->rows);                $clicksList = array_column($rows, 'clicks');                array_multisort($clicksList, SORT_DESC, $rows);                $totalClicks = array_sum($clicksList);                $fiveTotalRate = $fiveTotalClicks = 0;                for ($count = 0; $count < 5; $count++) {                    $rate = $rows[$count]['clicks'] / $totalClicks;                    $fiveTotalRate += $rate;                    $fiveTotalClicks += $rows[$count]['clicks'];                    WebmasterCountry::query()->create([                        'project_id' => $project['id'],                        'domain' => $project['webmaster_domain'],                        'clicks' => $rows[$count]['clicks'],                        'rate' => $rate,                        'country_code' => $rows[$count]['keys'][0],                        'country_zh' => $regions[strtoupper($rows[$count]['keys'][0])]['zh'],                        'create_time' => time(),                        'ym' => date('Ym', $startTime)                    ]);                }                WebmasterCountry::query()->create([                    'project_id' => $project['id'],                    'domain' => $project['webmaster_domain'],                    'clicks' => $totalClicks - $fiveTotalClicks,                    'rate' => 1 - $fiveTotalRate,                    'country_code' => '',                    'country_zh' => '其他',                    'create_time' => time(),                    'ym' => date('Ym', $startTime)                ]);            }        }    }    /**     * 将二维数组下的对象转为数组     * @param $data     * @return mixed     */    protected function objectToArray($data)    {        foreach ($data as &$item) {            $item = (array)$item;        }        return $data;    }    protected function regions()    {        return [            'ABW' => [                'en' => 'Aruba',                'zh' => '阿鲁巴岛'            ],            'AFG' => [                'en' => 'Afghanistan',                'zh' => '阿富汗'            ],            'AGO' => [                'en' => 'Angola',                'zh' => '安哥拉'            ],            'AIA' => [                'en' => 'Anguilla',                'zh' => '安圭拉岛'            ],            'ALA' => [                'en' => 'Aland Islands',//Åland Islands                'zh' => '阿兰群岛'            ],            'ALB' => [                'en' => 'Albania',                'zh' => '阿尔巴尼亚'            ],            'AND' => [                'en' => 'Andorra',                'zh' => '安道尔'            ],            'ARE' => [                'en' => 'United Arab Emirates',                'zh' => '阿拉伯联合酋长国'            ],            'ARG' => [                'en' => 'Argentina',                'zh' => '阿根廷'            ],            'ARM' => [                'en' => 'Armenia',                'zh' => '亚美尼亚'            ],            'ASM' => [                'en' => 'American Samoa',                'zh' => '美属萨摩亚'            ],            'ATA' => [                'en' => 'Antarctica',                'zh' => '南极洲'            ],            'ATF' => [                'en' => 'French Southern Territories',                'zh' => '法国南部地区'            ],            'ATG' => [                'en' => 'Antigua and Barbuda',                'zh' => '安提瓜和巴布达'            ],            'AUS' => [                'en' => 'Australia',                'zh' => '澳大利亚'            ],            'AUT' => [                'en' => 'Austria',                'zh' => '奥地利'            ],            'AZE' => [                'en' => 'Azerbaijan',                'zh' => '阿塞拜疆'            ],            'BDI' => [                'en' => 'Burundi',                'zh' => '布隆迪'            ],            'BEL' => [                'en' => 'Belgium',                'zh' => '比利时'            ],            'BEN' => [                'en' => 'Benin',                'zh' => '贝宁'            ],            'BES' => [                'en' => 'Bonaire, Sint Eustatius and Saba',                'zh' => '博奈尔,圣尤斯塔修斯和示巴'            ],            'BFA' => [                'en' => 'Burkina Faso',                'zh' => '布吉纳法索'            ],            'BGD' => [                'en' => 'Bangladesh',                'zh' => '孟加拉国'            ],            'BGR' => [                'en' => 'Bulgaria',                'zh' => '保加利亚'            ],            'BHR' => [                'en' => 'Bahrain',                'zh' => '巴林'            ],            'BHS' => [                'en' => 'Bahamas',                'zh' => '巴哈马群岛'            ],            'BIH' => [                'en' => 'Bosnia and Herzegovina',                'zh' => '波斯尼亚和黑塞哥维那'            ],            'BLM' => [                'en' => 'Saint Barthélemy',                'zh' => '圣巴特尔米'            ],            'BLR' => [                'en' => 'Belarus',                'zh' => '白俄罗斯'            ],            'BLZ' => [                'en' => 'Belize',                'zh' => '伯利兹'            ],            'BMU' => [                'en' => 'Bermuda',                'zh' => '百慕大'            ],            'BOL' => [                'en' => 'Bolivia(Plurinational State of)',                'zh' => '玻利维亚'            ],            'BRA' => [                'en' => 'Brazil',                'zh' => '巴西'            ],            'BRB' => [                'en' => 'Barbados',                'zh' => '巴巴多斯'            ],            'BRN' => [                'en' => 'Brunei Darussalam',                'zh' => '文莱'            ],            'BTN' => [                'en' => 'Bhutan',                'zh' => '不丹'            ],            'BVT' => [                'en' => 'Bouvet Island',                'zh' => '布维岛'            ],            'BWA' => [                'en' => 'Botswana',                'zh' => '博茨瓦纳'            ],            'CAF' => [                'en' => 'Central African Republic',                'zh' => '中非共和国'            ],            'CAN' => [                'en' => 'Canada',                'zh' => '加拿大'            ],            'CCK' => [                'en' => 'Cocos(Keeling) Islands',                'zh' => '科科斯(基林)群岛'            ],            'CHE' => [                'en' => 'Switzerland',                'zh' => '瑞士'            ],            'CHL' => [                'en' => 'Chile',                'zh' => '智利'            ],            'CHN' => [                'en' => 'China',                'zh' => '中国'            ],            'CIV' => [                'en' => 'Cote d\'Ivoire',//Côte d'Ivoire                'zh' => '科特迪瓦'            ],            'CMR' => [                'en' => 'Cameroon',                'zh' => '喀麦隆'            ],            'COD' => [                'en' => 'Congo, Democratic Republic of the',                'zh' => '刚果,民主共和国'            ],            'COG' => [                'en' => 'Congo',                'zh' => '刚果'            ],            'COK' => [                'en' => 'Congo',                'zh' => '库克群岛'            ],            'COL' => [                'en' => 'Colombia',                'zh' => '哥伦比亚'            ],            'COM' => [                'en' => 'Comoros',                'zh' => '科摩罗'            ],            'CPV' => [                'en' => 'Cabo Verde',                'zh' => '佛得角'            ],            'CRI' => [                'en' => 'Costa Rica',                'zh' => '哥斯达黎加'            ],            'CUB' => [                'en' => 'Cuba',                'zh' => '古巴'            ],            'CUW' => [                'en' => 'Curaçao',                'zh' => 'Curaçao'            ],            'CXR' => [                'en' => 'Christmas Island',                'zh' => '圣诞岛'            ],            'CYM' => [                'en' => 'Cayman Islands',                'zh' => '开曼群岛'            ],            'CYP' => [                'en' => 'Cyprus',                'zh' => '塞浦路斯'            ],            'CZE' => [                'en' => 'Czechia',                'zh' => '捷克'            ],            'DEU' => [                'en' => 'Germany',                'zh' => 'Germany'            ],            'DJI' => [                'en' => 'Djibouti',                'zh' => '吉布提'            ],            'DMA' => [                'en' => 'Dominica',                'zh' => '多米尼加'            ],            'DNK' => [                'en' => 'Denmark',                'zh' => '丹麦'            ],            'DOM' => [                'en' => 'Dominican Republic',                'zh' => '多米尼加共和国'            ],            'DZA' => [                'en' => 'Algeria',                'zh' => 'Algeria'            ],            'ECU' => [                'en' => 'Ecuador',                'zh' => 'Ecuador'            ],            'EGY' => [                'en' => 'Egypt',                'zh' => '埃及'            ],            'ERI' => [                'en' => 'Eritrea',                'zh' => '厄立特里亚'            ],            'ESH' => [                'en' => 'Western Sahara',                'zh' => '西撒哈拉'            ],            'ESP' => [                'en' => 'Spain',                'zh' => '西班牙'            ],            'EST' => [                'en' => 'Estonia',                'zh' => '爱沙尼亚'            ],            'ETH' => [                'en' => 'Ethiopia',                'zh' => '埃塞俄比亚'            ],            'FIN' => [                'en' => 'Finland',                'zh' => '芬兰'            ],            'FJI' => [                'en' => 'Fiji',                'zh' => '斐济'            ],            'FLK' => [                'en' => 'Falkland Islands(Malvinas)',                'zh' => '福克兰群岛(马尔维纳斯群岛)'            ],            'FRA' => [                'en' => 'France',                'zh' => '法国'            ],            'FRO' => [                'en' => 'Faroe Islands',                'zh' => 'Faroe Islands'            ],            'FSM' => [                'en' => 'Micronesia(Federated States of)',                'zh' => '密克罗尼西亚(联邦)'            ],            'GAB' => [                'en' => 'Gabon',                'zh' => '加蓬'            ],            'GBR' => [                'en' => 'United Kingdom of Great Britain and Northern Ireland',                'zh' => '英国'            ],            'GEO' => [                'en' => 'Georgias',                'zh' => '乔治亚州'            ],            'GGY' => [                'en' => 'Guernsey',                'zh' => '根西岛'            ],            'GHA' => [                'en' => 'Ghana',                'zh' => '加纳'            ],            'GIB' => [                'en' => 'Gibraltar',                'zh' => '直布罗陀'            ],            'GIN' => [                'en' => 'Guinea',                'zh' => '几内亚'            ],            'GLP' => [                'en' => 'Guadeloupe',                'zh' => '瓜德罗普岛'            ],            'GMB' => [                'en' => 'Gambia',                'zh' => '冈比亚'            ],            'GNB' => [                'en' => 'Guinea - Bissau',                'zh' => '几内亚-比绍'            ],            'GNQ' => [                'en' => 'Equatorial Guinea',                'zh' => '赤道几内亚'            ],            'GRC' => [                'en' => 'Greece',                'zh' => '希腊'            ],            'GRD' => [                'en' => 'Grenada',                'zh' => '格林纳达'            ],            'GRL' => [                'en' => 'Greenland',                'zh' => '格陵兰岛'            ],            'GTM' => [                'en' => 'Guatemala',                'zh' => '危地马拉'            ],            'GUF' => [                'en' => 'French Guiana',                'zh' => '法属圭亚那'            ],            'GUM' => [                'en' => 'Guam',                'zh' => '关岛'            ],            'GUY' => [                'en' => 'Guyana',                'zh' => '圭亚那'            ],            'HKG' => [                'en' => 'Hong Kong',                'zh' => '中国香港'            ],            'HMD' => [                'en' => 'Heard Island and McDonald Islands',                'zh' => '赫德岛和麦克唐纳岛'            ],            'HND' => [                'en' => 'Honduras',                'zh' => '洪都拉斯'            ],            'HRV' => [                'en' => 'Croatia',                'zh' => '克罗地亚'            ],            'HTI' => [                'en' => 'Haiti',                'zh' => '海地'            ],            'HUN' => [                'en' => 'Hungary',                'zh' => '匈牙利'            ],            'IDN' => [                'en' => 'Indonesia',                'zh' => '印度尼西亚'            ],            'IMN' => [                'en' => 'Isle of Man',                'zh' => '英国属地曼岛'            ],            'IND' => [                'en' => 'India',                'zh' => '印度'            ],            'IOT' => [                'en' => 'British Indian Ocean Territory',                'zh' => '英属印度洋领土'            ],            'IRL' => [                'en' => 'Ireland',                'zh' => '爱尔兰'            ],            'IRN' => [                'en' => 'Iran(Islamic Republic of)',                'zh' => '伊朗(伊斯兰共和国)'            ],            'IRQ' => [                'en' => 'Iraq',                'zh' => '伊拉克'            ],            'ISL' => [                'en' => 'Iceland',                'zh' => '冰岛'            ],            'ISR' => [                'en' => 'Israel',                'zh' => '以色列'            ],            'ITA' => [                'en' => 'Italy',                'zh' => '意大利'            ],            'JAM' => [                'en' => 'Jamaica',                'zh' => '牙买加'            ],            'JEY' => [                'en' => 'Jersey',                'zh' => '泽西岛'            ],            'JOR' => [                'en' => 'Jordan',                'zh' => '约旦'            ],            'JPN' => [                'en' => 'Japan',                'zh' => '日本'            ],            'KAZ' => [                'en' => 'Kazakhstan',                'zh' => '哈萨克斯坦'            ],            'KEN' => [                'en' => 'Kenya',                'zh' => '肯尼亚'            ],            'KGZ' => [                'en' => 'Kyrgyzstan',                'zh' => '吉尔吉斯斯坦'            ],            'KHM' => [                'en' => 'Cambodia',                'zh' => '柬埔寨'            ],            'KIR' => [                'en' => 'Kiribati',                'zh' => 'Kiribati'            ],            'KNA' => [                'en' => 'Saint Kitts and Nevis',                'zh' => '圣基茨和尼维斯'            ],            'KOR' => [                'en' => 'Korea, Republic of',                'zh' => '朝鲜共和国'            ],            'KWT' => [                'en' => 'Kuwait',                'zh' => '科威特'            ],            'LAO' => [                'en' => 'Lao People\'s Democratic Republic',                'zh' => ''            ],            'LBN' => [                'en' => 'Lebanon',                'zh' => '黎巴嫩'            ],            'LBR' => [                'en' => 'Liberia',                'zh' => '利比里亚'            ],            'LBY' => [                'en' => 'Libya',                'zh' => '利比亚'            ],            'LCA' => [                'en' => 'Saint Lucia',                'zh' => '圣卢西亚岛'            ],            'LIE' => [                'en' => 'Liechtenstein',                'zh' => '列支敦斯登'            ],            'LKA' => [                'en' => 'Sri Lanka',                'zh' => '斯里兰卡'            ],            'LSO' => [                'en' => 'Lesotho',                'zh' => '莱索托'            ],            'LTU' => [                'en' => 'Lithuania',                'zh' => '立陶宛'            ],            'LUX' => [                'en' => 'Luxembourg',                'zh' => '卢森堡'            ],            'LVA' => [                'en' => 'Latvia',                'zh' => '拉脱维亚'            ],            'MAC' => [                'en' => 'Macao',                'zh' => '中国澳门'            ],            'MAF' => [                'en' => 'Saint Martin(French part)',                'zh' => '圣马丁(法国)'            ],            'MAR' => [                'en' => 'Morocco',                'zh' => '摩洛哥'            ],            'MCO' => [                'en' => 'Monaco',                'zh' => '摩纳哥'            ],            'MDA' => [                'en' => 'Moldova, Republic of',                'zh' => '摩尔多瓦共和国'            ],            'MDG' => [                'en' => 'Madagascar',                'zh' => 'Madagascar'            ],            'MDV' => [                'en' => 'Maldives',                'zh' => '马尔代夫'            ],            'MEX' => [                'en' => 'Mexico',                'zh' => '墨西哥'            ],            'MHL' => [                'en' => 'Marshall Islands',                'zh' => '马绍尔群岛'            ],            'MKD' => [                'en' => 'Macedonia, the former Yugoslav Republic of',                'zh' => '马其顿,前南斯拉夫共和国'            ],            'MLI' => [                'en' => 'Mali',                'zh' => '马里'            ],            'MLT' => [                'en' => 'Malta',                'zh' => 'Malta'            ],            'MMR' => [                'en' => 'Myanmar',                'zh' => '缅甸'            ],            'MNE' => [                'en' => 'Montenegro',                'zh' => '黑山共和国'            ],            'MNG' => [                'en' => 'Mongolia',                'zh' => '蒙古'            ],            'MNP' => [                'en' => 'Northern Mariana Islands',                'zh' => '北马里亚纳群岛'            ],            'MOZ' => [                'en' => 'Mozambique',                'zh' => '莫桑比克'            ],            'MRT' => [                'en' => 'Mauritania',                'zh' => '毛利塔尼亚'            ],            'MSR' => [                'en' => 'Montserrat',                'zh' => '蒙特塞拉特'            ],            'MTQ' => [                'en' => 'Martinique',                'zh' => '马提尼克岛'            ],            'MUS' => [                'en' => 'Mauritius',                'zh' => '毛里求斯'            ],            'MWI' => [                'en' => 'Malawi',                'zh' => '马拉维'            ],            'MYS' => [                'en' => 'Malaysia',                'zh' => '马来西亚'            ],            'MYT' => [                'en' => 'Mayotte',                'zh' => '科摩罗马约特岛'            ],            'NAM' => [                'en' => 'Namibia',                'zh' => '纳米比亚'            ],            'NCL' => [                'en' => 'New Caledonia',                'zh' => '新喀里多尼亚'            ],            'NER' => [                'en' => 'Niger',                'zh' => '尼日尔'            ],            'NFK' => [                'en' => 'Norfolk Island',                'zh' => '诺福克岛'            ],            'NGA' => [                'en' => 'Nigeria',                'zh' => '尼日利亚'            ],            'NIC' => [                'en' => 'Nicaragua',                'zh' => '尼加拉瓜'            ],            'NIU' => [                'en' => 'Niue',                'zh' => '纽埃岛'            ],            'NLD' => [                'en' => 'Netherlands',                'zh' => '荷兰'            ],            'NOR' => [                'en' => 'Norway',                'zh' => '挪威'            ],            'NPL' => [                'en' => 'Nepal',                'zh' => '尼泊尔'            ],            'NRU' => [                'en' => 'Nauru',                'zh' => '瑙鲁'            ],            'NZL' => [                'en' => 'New Zealand',                'zh' => '新西兰'            ],            'OMN' => [                'en' => 'Oman',                'zh' => '阿曼'            ],            'PAK' => [                'en' => 'Pakistan',                'zh' => '巴基斯坦'            ],            'PAN' => [                'en' => 'Panama',                'zh' => '巴拿马'            ],            'PCN' => [                'en' => 'Pitcairn',                'zh' => '皮特克恩'            ],            'PHL' => [                'en' => 'Philippines',                'zh' => '菲律宾'            ],            'PER' => [                'en' => 'Peru',                'zh' => '秘鲁'            ],            'PLW' => [                'en' => 'Palau',                'zh' => '帕劳'            ],            'PNG' => [                'en' => 'Papua New Guinea',                'zh' => '巴布新几内亚'            ],            'POL' => [                'en' => 'Poland',                'zh' => '波兰'            ],            'PRI' => [                'en' => 'Puerto Rico',                'zh' => '波多黎各'            ],            'PRK' => [                'en' => 'Korea(Democratic People\'s Republic of)',                'zh' => '朝鲜(民主主义人民共和国)'            ],            'PRT' => [                'en' => 'Portugal',                'zh' => '葡萄牙'            ],            'PRY' => [                'en' => 'Paraguay',                'zh' => '巴拉圭'            ],            'PSE' => [                'en' => 'Palestine, State of',                'zh' => '巴勒斯坦'            ],            'PYF' => [                'en' => 'French Polynesia',                'zh' => '法属波利尼西亚'            ],            'QAT' => [                'en' => 'Qatar',                'zh' => '卡塔尔'            ],            'REU' => [                'en' => 'Réunion',                'zh' => '留尼汪'            ],            'ROU' => [                'en' => 'Romania',                'zh' => 'Romania'            ],            'RUS' => [                'en' => 'Russian Federation',                'zh' => '俄罗斯联邦'            ],            'RWA' => [                'en' => 'Rwanda',                'zh' => '卢旺达'            ],            'SAU' => [                'en' => 'Saudi Arabia',                'zh' => '沙特阿拉伯'            ],            'SDN' => [                'en' => 'Sudan',                'zh' => '苏丹'            ],            'SEN' => [                'en' => 'Senegal',                'zh' => '塞内加尔'            ],            'SGP' => [                'en' => 'Singapore',                'zh' => '新加坡'            ],            'SGS' => [                'en' => 'South Georgia and the South Sandwich Islands',                'zh' => '南乔治亚和南桑威奇群岛'            ],            'SHN' => [                'en' => 'Saint Helena, Ascension and Tristan da Cunha',                'zh' => '圣海伦娜,阿森松和特里斯坦·达库尼亚'            ],            'SJM' => [                'en' => 'Svalbard and Jan Mayen',                'zh' => '斯瓦尔巴特群岛和扬·马延'            ],            'SLB' => [                'en' => 'Solomon Islands',                'zh' => '所罗门群岛'            ],            'SLE' => [                'en' => 'Sierra Leone',                'zh' => '塞拉利昂'            ],            'SLV' => [                'en' => 'El Salvador',                'zh' => '萨尔瓦多'            ],            'SMR' => [                'en' => 'San Marino',                'zh' => '圣马力诺'            ],            'SOM' => [                'en' => 'Somalia',                'zh' => '索马里'            ],            'SPM' => [                'en' => 'Saint Pierre and Miquelon',                'zh' => '圣皮埃尔和密克隆'            ],            'SRB' => [                'en' => 'Serbia',                'zh' => '塞尔维亚'            ],            'SSD' => [                'en' => 'South Sudan',                'zh' => '南苏丹'            ],            'STP' => [                'en' => 'Sao Tome and Principe',                'zh' => '圣多美和普林西比'            ],            'SUR' => [                'en' => 'Suriname',                'zh' => '苏里南'            ],            'SVK' => [                'en' => 'Slovakia',                'zh' => '斯洛伐克'            ],            'SVN' => [                'en' => 'Slovenia',                'zh' => '斯洛文尼亚'            ],            'SWE' => [                'en' => 'Sweden',                'zh' => '瑞典'            ],            'SWZ' => [                'en' => 'Eswatini',                'zh' => '斯威士兰'            ],            'SXM' => [                'en' => 'Sint Maarten(Dutch part)',                'zh' => '荷属圣马丁'            ],            'SYC' => [                'en' => 'Seychelles',                'zh' => '塞舌尔'            ],            'SYR' => [                'en' => 'Syrian Arab Republic',                'zh' => '阿拉伯叙利亚共和国'            ],            'TCA' => [                'en' => 'Turks and Caicos Islands',                'zh' => '特克斯和凯科斯群岛'            ],            'TCD' => [                'en' => 'Chad',                'zh' => '乍得'            ],            'TGO' => [                'en' => 'Togo',                'zh' => '多哥'            ],            'THA' => [                'en' => 'Thailand',                'zh' => '泰国'            ],            'TJK' => [                'en' => 'Tajikistan',                'zh' => '塔吉克斯坦'            ],            'TKL' => [                'en' => 'Tokelau',                'zh' => '托克劳'            ],            'TKM' => [                'en' => 'Turkmenistan',                'zh' => '土库曼斯坦'            ],            'TLS' => [                'en' => 'Timor - Leste',                'zh' => '东帝汶'            ],            'TON' => [                'en' => 'Tonga',                'zh' => '汤加'            ],            'TTO' => [                'en' => 'Trinidad and Tobago',                'zh' => '特立尼达和多巴哥'            ],            'TUN' => [                'en' => 'Tunisia',                'zh' => '突尼斯'            ],            'TUR' => [                'en' => 'Turkey',                'zh' => '土耳其'            ],            'TUV' => [                'en' => 'Tuvalu',                'zh' => '图瓦卢'            ],            'TWN' => [                'en' => 'Taiwan, Province of China',                'zh' => '中国台湾'            ],            'TZA' => [                'en' => 'Tanzania, United Republic of',                'zh' => '坦桑尼亚'            ],            'UGA' => [                'en' => 'Uganda',                'zh' => '乌干达'            ],            'UKR' => [                'en' => 'Ukraine',                'zh' => '乌克兰'            ],            'UMI' => [                'en' => 'United States Minor Outlying Islands',                'zh' => '美国本土外小岛屿'            ],            'URY' => [                'en' => 'Uruguay',                'zh' => '乌拉圭'            ],            'USA' => [                'en' => 'United States of America',                'zh' => '美国'            ],            'UZB' => [                'en' => 'Uzbekistan',                'zh' => '乌兹别克斯坦'            ],            'VAT' => [                'en' => 'Holy See',                'zh' => '圣座'            ],            'VCT' => [                'en' => 'Saint Vincent and the Grenadines',                'zh' => '圣文森特和格林纳丁斯'            ],            'VEN' => [                'en' => 'Venezuela(Bolivarian Republic of)',                'zh' => '委内瑞拉(玻利瓦尔共和国)'            ],            'VGB' => [                'en' => 'Virgin Islands(British)',                'zh' => '维尔京群岛(英国)'            ],            'VIR' => [                'en' => 'Virgin Islands(U . S .)',                'zh' => '维尔京群岛'            ],            'VNM' => [                'en' => 'Viet Nam',                'zh' => 'Viet Nam'            ],            'VUT' => [                'en' => 'Vanuatu',                'zh' => '瓦努阿图'            ],            'WLF' => [                'en' => 'Wallis and Futuna',                'zh' => '瓦利斯群岛和富图纳群岛'            ],            'WSM' => [                'en' => 'Samoa',                'zh' => '萨摩亚'            ],            'YEM' => [                'en' => 'Yemen',                'zh' => '也门'            ],            'ZAF' => [                'en' => 'South Africa',                'zh' => '南非'            ],            'ZMB' => [                'en' => 'Zambia',                'zh' => '赞比亚'            ],            'ZWE' => [                'en' => 'Zimbabwe',                'zh' => '津巴布韦'            ]        ];    }}
 |