PHP 百度推送代码,必应bing站长网站管理员工具API推送代码
public function pushBaidu($urls){
$api = 'http://data.zz.baidu.com/urls?site=https://www.php-china.com&token=你自己的百度网站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'];
//生成网站地图xml写入日志
event(new AdminOperatingEvent(ApiOperating::AUTOMATIC_SITE_MAP_PUSH,intval(999999)));
Log::info('网站地图推送百度成功推送:'.$success);
Log::info('网站地图推送百度当天剩余次数:'.$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('网站地图推送bing成功推送');
}
$api = 'http://data.zz.baidu.com/urls?site=https://www.php-china.com&token=你自己的百度网站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'];
//生成网站地图xml写入日志
event(new AdminOperatingEvent(ApiOperating::AUTOMATIC_SITE_MAP_PUSH,intval(999999)));
Log::info('网站地图推送百度成功推送:'.$success);
Log::info('网站地图推送百度当天剩余次数:'.$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('网站地图推送bing成功推送');
}
版权声明: 本站仅提供信息存储空间服务,旨在传递更多信息,不拥有所有权,不承担相关法律责任,不代表本网赞同其观点和对其真实性负责。如因作品内容、版权和其它问题需要同本网联系的,请发送邮件至 举报,一经查实,本站将立刻删除。