百度链接提交三种方式:
1、主动推送:最为快速的提交方式,推荐您将站点当天新产出链接立即通过此方式推送给百度,以保证新链接可以及时被百度收录。
2、sitemap:您可以定期将网站链接放到sitemap中,然后将sitemap提交给百度。百度会周期性的抓取检查您提交的sitemap,对其中的链接进行处理,但收录速度慢于主动推送。
下面介绍使用curl主动推送链接的方式PHP示例,使用curl扩展:
$urls = array(
'http://www.example.com/1.html',
'http://www.example.com/2.html',
);
$api = 'http://data.zz.baidu.com/urls?site=www.dayecn.com&token=Db0ZoYUOwUyEp87Z';
$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'),
); //Cuoxin.com
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;
推送成功
状态码为200,可能返回以下字段:
字段 是否必选 参数类型 说明
success 是 int 成功推送的url条数
remain 是 int 当天剩余的可推送url条数
not_same_site 否 array 由于不是本站url而未处理的url列表
not_valid 否 array 不合法的url列表
成功返回示例:
{
"remain":4999998,
"success":2,
"not_same_site":[],
"not_valid":[]
}
推送失败
状态码为4xx,返回字段有:
字段 是否必传 类型 说明
error 是 int 错误码,与状态码相同
message 是 string 错误描述
失败返回示例:
{
"error":401,
"message":"token is not valid"
}
大型站长资讯类网站! https://www.0455zz.com