织梦sitemap舆图及时推收办法分享
织梦sitemap舆图及时推收办法分享:百度主动推收对站少们去道借是很主要的,百度又出了及时推收链接的地点,那样必定比sitemap便利多了,并且也能够确保文章的本创性。我把年夜神的文章收拾整顿了一下拿去跟各人分享分享。
1、脚动创立一个文件,天天会见那个文件便能够把当天的局部文章推收到百度搜刮引擎.
正在根目次上面创立一个fcz8k.php会见后会返回百度接心成果代码以下:
require_once ("include/common.inc.php");
require_once "include/arc.partview.class.php";
require_once('include/charset.func.php');
$year = date("Y");
$month = date("m");
$day = date("d");
$dayBegin = mktime(0,0,0,$month,$day,$year);//当天开端工夫戳
$dayEnd = mktime(23,59,59,$month,$day,$year);//当天完毕工夫戳
$query = "SELECT arch.id,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate<".$dayEnd." AND pubdate>".$dayBegin.""; //那里dede换成您们本人的表前缀
$urls="";
$dsql->Execute('arch.id,types.typedir',$query);
while($row = $dsql->GetArray('arch.id,types.typedir')) {
$urls.="*****".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";
//将上边的*****换成您的网址
}
$urls=substr($urls,0,-1);
$urls = explode(",",$urls);
$api = 'data.zz.百度/urls?site=******&token=xxxxx'; // 前边的site换成本人的site xxx换成本人的稀钥
$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);
echo $result.count($urls); ?>
百度接心返回阐明:
推收胜利
形态码为200,能够返回以下字段:
织梦主动推收胜利
胜利返回示例:
{
"remain":4999998,
"success":2,
"not_same_site":[],
"not_valid":[]
}
推收失利
形态码为4xx,返回字段有:
织梦主动推收失利
失利返回示例:
{
"error":401,
"message":"token is not valid"
}
2、 第两种是公布一篇文章,便像百度推收一次,那种比力便利。
翻开织梦背景的 article_add.php 文件.找赴任没有多262止的模样 参加以下代码
$urls=“fcz8k".$artUrl;//前里域名换成您本人的
$urls = explode(",",$urls);
$api = 'data.zz.百度/urls?site=fcz8k&token=xxxx'; // 前边site换成本人的site xxx换成本人的稀钥
$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);
便OK了 ,假如念看增加胜利出,能够正在修正上面一两止的模样的代码
请挑选您的后绝操纵".$result.$urls[0].":
result是看百度返回的成果,urls是看您推收的url.
假如您念让修正文章的时分也究竟推收,便相似上里一样来修正article_edit.php便好了.
滥觞:搜索引擎优化why,做者:生成柚稚笨
相关信息
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|