Interface calling address: http://ping.baidu.com/sitemap?site=www.xxx.com&resource_name=sitemap&access_token=XXXXXXX
Parameter
site is string The site verified on the webmaster platform, such as www.example.com
resource_name You The name of the data that is allowed to be pushed, such as RDF_BBS_Thread or sitemap
access_token is the string access key for push applied on the webmaster platform
This method is only applicable to sites that have opened Baidu sitemap permissions. You can ping directly when the page is updated. To Baidu. Can be viewed in Baidu backend
Feedback code
200 No usage error, need to further observe whether the returned content is correct
400 Required parameters are not provided
405 Unsupported request method, we only support POST method to submit data
411 HTTP The Content-Length field is missing in the header
413 The pushed data is too large and exceeds the 10MB limit
422 The length declared by Content-Length in the HTTP header is inconsistent with the length of the actual data sent
500 Webmaster platform server internal error
function tobaidu($url){ $ntime=time(); $now = date('Y-m-d',$ntime); $data ='<?xml version="1.0" encoding="UTF-8"?>'; $data .=' <urlset>'; $data .=' <url>'; $data .=' <loc><![CDATA['.$url.']]></loc>'; $data .=' <lastmod>'.$now.'</lastmod>'; $data .=' <changefreq>daily</changefreq>'; $data .=' <priority>0.8</priority>'; $data .=' </url>'; $data .=' </urlset>'; $pingurl="http://ping.baidu.com/sitemap?site=www.xxx.com&resource_name=sitemap&access_token=XXXXXXX";//你的接口地址 $curl = curl_init(); // 启动一个CURL会话 curl_setopt($curl, CURLOPT_URL, $pingurl); // 要访问的地址 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查 curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); // 从证书中检查SSL加密算法是否存在 curl_setopt($curl, CURLOPT_USERAGENT, "curl/7.12.1"); // 模拟用户使用的浏览器 curl_setopt($curl, CURLOPT_COOKIE, $cookie); curl_setopt($curl, CURLOPT_REFERER,""); curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求 curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包 curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环 curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回 $tmpInfo = curl_exec($curl); // 执行操作 if (curl_errno($curl)) { echo 'Errno'.curl_error($curl);//捕抓异常 } curl_close($curl); // 关闭CURL会话 return $tmpInfo; // 返回数据 } $tt= tobaidu("http://www.appleshu.com/");