必应、百度、搜狗、360收录wordpress链接提交推送

1.必应站长后台

https://www.bing.com/webmasters

点右上角的设置按钮(齿轮⚙)

找到你的apikey,如图

第二步

2.百度接口地址,查看这里

https://ziyuan.baidu.com/linksubmit/index

神马搜索推送接口查看

https://zhanzhang.sm.cn/open/mip

将以下代码放到你的主题的functions.php里面

//add_action( 'publish_future_post', 'send_searchEnginePost' );
add_action( 'publish_post', 'send_searchEnginePost' );
function send_searchEnginePost($postid)
{

	if(get_post_status($postid) == "publish"){

		$article_fullurl = get_permalink($postid);
		//静态页格式
		$article_fullurl = 'https://www.freebasic.cn/p/'.$postid.".html";

		$urls            = array('{"siteUrl":"https://www.freebasic.cn", "url": "' . $article_fullurl . '"}');
		$api     = 'https://ssl.bing.com/webmaster/api.svc/json/SubmitUrl?apikey=5dc512aa6eaf453bb108a6c10fc3xxxx'; //apikey改成你自己的
		//必应提交
		$ch      = curl_init();
		$options = array(
			CURLOPT_URL           => $api,
			CURLOPT_POST          => true,
			CURLOPT_RETURNTRANSFER=> true,
			CURLOPT_POSTFIELDS    => implode("\n", $urls),
			CURLOPT_HTTPHEADER         => array('Content-Type: application/json','charset: utf-8'),
		);
		curl_setopt_array($ch, $options);
		$result = curl_exec($ch);
		// echo $result;
		$time   = time();
		$file   = dirname(__FILE__).'/bingSubmit.txt';
		if(date('Y-m-d',filemtime($file)) != date('Y-m-d')){
			$handle = fopen($file,"w");
		}
		else
		{
			$handle = fopen($file,"a");
		}
		$resultMessage = "";
		if($result['message']){
			$resultMessage = date('Y-m-d G:i:s',$time)."\n提交失败".$result['message'].":\n网址:".$article_fullurl."\n\n".$result;
		}
		if($result['success']){
			$resultMessage = date('Y-m-d G:i:s',$time)."\n提交成功".":".$article_fullurl."\n\n";
		}
		fwrite($handle,$resultMessage);
		fclose($handle);

		//百度提交
		$urls = array(
			$article_fullurl,
		);
		$api     = 'http://data.zz.baidu.com/urls?site=https://www.freebasic.cn&token=OszASDy8MScmxxxx'; //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);
		// echo $result;
		$time   = time();
		$file   = dirname(__FILE__).'/baiduSubmit.txt';
		if(date('Y-m-d',filemtime($file)) != date('Y-m-d')){
			$handle = fopen($file,"w");
		}
		else
		{
			$handle = fopen($file,"a");
		}
		$resultMessage = "";
		if($result['message']){
			$resultMessage = date('Y-m-d G:i:s',$time)."\n提交失败".$result['message'].":\n网址:".$article_fullurl."\n\n".$result;
		}
		if($result['success']){
			$resultMessage = date('Y-m-d G:i:s',$time)."\n提交成功".":".$article_fullurl."\n\n";
		}
		fwrite($handle,$resultMessage);
		fclose($handle);

		//搜狗提交
		$postUrl = 'http://fankui.help.sogou.com/index.php/web/web/addShoulu';
		$postData= array(
			"source"   => "1",
			"site_type"=> "1",
			"Shoulu"       => array("webAdr"=>$article_fullurl,"email" =>"xxxx@163.com","reason"=>"".get_post($postid)->post_title)
		); //邮箱改成你自己的
		$postData = http_build_query($postData);
		$curl     = curl_init();
		curl_setopt($curl, CURLOPT_URL, $postUrl);
		curl_setopt($curl, CURLOPT_USERAGENT,'Opera/9.80 (Windows NT 6.2; Win64; x64) Presto/2.12.388 Version/12.15');
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // stop verifying certificate
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($curl, CURLOPT_POST, true);
		curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
		curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
		$r    = curl_exec($curl);
		curl_close($curl);
		$file = dirname(__FILE__).'/sogouSubmit.txt';
		if(date('Y-m-d',filemtime($file)) != date('Y-m-d')){
			$handle = fopen($file,"w");
		}
		else
		{
			$handle = fopen($file,"a");
		}
		$resultMessage = "";
		if($result['message']){
			$resultMessage = date('Y-m-d G:i:s',$time)."\n提交失败".$result['message'].":\n网址:".$article_fullurl."\n\n".$result;
		}
		if($result['success']){
			$resultMessage = date('Y-m-d G:i:s',$time)."\n提交成功".":".$article_fullurl."\n\n";
		}
		fwrite($handle,$resultMessage);
		fclose($handle);

		//神马提交
		$urls = array(
			$article_fullurl,
		);
		$api     = 'https://data.zhanzhang.sm.cn/push?site=www.freebasic.cn&user_name=venski@163.com&resource_name=mip_add&token=TI_9ca82cd074712371b55ceff35de0e6d8';
		$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);
		$time   = time();
		$file   = dirname(__FILE__).'/smcnSubmit.txt';
		if(date('Y-m-d',filemtime($file)) != date('Y-m-d')){
			$handle = fopen($file,"w");
		}
		else
		{
			$handle = fopen($file,"a");
		}
		$resultMessage = "";
		if($result['message']){
			$resultMessage = date('Y-m-d G:i:s',$time)."\n提交失败".$result['message'].":\n网址:".$article_fullurl."\n\n".$result;
		}
		if($result['success']){
			$resultMessage = date('Y-m-d G:i:s',$time)."\n提交成功".":".$article_fullurl."\n\n";
		}
		fwrite($handle,$resultMessage);
		fclose($handle);
	}
}

360提交的方法是访问

http://zhanzhang.so.com/sitetool/auto_include

获取代码放在你的主题 footer.php 里面即可。

另附sitemap提交地址

https://www.bing.com/webmasters/sitemaps

https://ziyuan.baidu.com/linksubmit/index

http://zhanzhang.so.com/sitetool/sitemap

点赞