利用post推送文章至百度

操作教程

1.网站根目录下建 post.php文件 并加入代码

<?
header('Content-Type:text/html;charset=utf-8');
$xmldata =file_get_contents("https://www.xinua.cn/wp-sitemap-posts-post-38.xml");
$xmlstring = simplexml_load_string($xmldata,'SimpleXMLElement',LIBXML_NOCDATA);
$value_array = json_decode(json_encode($xmlstring),true);
$url = [];
for ($i =0;$i < count($value_array['url']);$i++){
    echo $value_array['url'][$i]['loc']."<br/>";
    $url[]= $value_array['url'][$i]['loc'];
}
$api ='百度推送链接';
$ch = curl_init();
$options = array(
   CURLOPT_URL => $api,
   CURLOPT_POST => true,
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_POSTFIELDS => implode("\n",$url),
   CURLOPT_HTTPHEADER => array('Content-Type:text/plain'),
);
curl_setopt_array($ch, $options);
$result =curl_exec($ch);
echo $result;

2.修改https://www.xinua.cn/wp-sitemap-posts-post-38.xml为自己地图地址

3.打开即可(你的域名/post.php)

                       

点击阅读全文

上一篇 2021年4月2日 am12:04
下一篇 2021年4月2日 am12:27