亚洲欧美成人综合一区_国产精品一区二区无码_亚洲风情偷拍区_成?人免费无码视频在线看

當(dāng)前位置:首頁 > 學(xué)習(xí)>正文

PHP 百度推送代碼,必應(yīng)bing站長網(wǎng)站管理員工具API推送代碼

   public function pushBaidu($urls){
        $api = 'http://data.zz.baidu.com/urls?site=https://www.php-china.com&token=你自己的百度網(wǎng)站token';
        $ch = curl_init();
        $options =  array(
            CURLOPT_URL => $api,
            CURLOPT_POST => true,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POSTFIELDS => implode("\n", $urls),
            CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
        );
        curl_setopt_array($ch, $options);
        $result = curl_exec($ch);
        $arrRes = json_decode($result,true);
        $remain = $arrRes['remain'];
        $success = $arrRes['success'];
        //生成網(wǎng)站地圖xml寫入日志
        event(new AdminOperatingEvent(ApiOperating::AUTOMATIC_SITE_MAP_PUSH,intval(999999)));
        Log::info('網(wǎng)站地圖推送百度成功推送:'.$success);
        Log::info('網(wǎng)站地圖推送百度當(dāng)天剩余次數(shù):'.$remain);
    }

    public function pushBing($arr,$webUrl){
        $key="你自己的bing密鑰";
        $api = "https://ssl.bing.com/webmaster/api.svc/json/SubmitUrlbatch?apikey=".$key;
        $urls=[
            "siteUrl"=>$webUrl,
            "urlList"=>[]
        ];
        foreach ($arr as $k => $v) {
            if($k>0){
                array_push($urls['urlList'],$v);
            }
        }
        $ch = curl_init();
        $options =  array(
            CURLOPT_URL => $api,
            CURLOPT_POST => true,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => "",
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "POST",
            CURLOPT_POSTFIELDS => json_encode($urls),
            CURLOPT_HTTPHEADER => array(
                "Accept: application/json",
                "Content-Type: application/json"
            ),
        );
        curl_setopt_array($ch, $options);
        $result = curl_exec($ch);
        $arrRes = json_decode($result,true);
        $arrRes["d"];
        Log::info('網(wǎng)站地圖推送bing成功推送');
    }
 

版權(quán)聲明: 本站僅提供信息存儲空間服務(wù),旨在傳遞更多信息,不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任,不代表本網(wǎng)贊同其觀點和對其真實性負(fù)責(zé)。如因作品內(nèi)容、版權(quán)和其它問題需要同本網(wǎng)聯(lián)系的,請發(fā)送郵件至 舉報,一經(jīng)查實,本站將立刻刪除。

猜你喜歡