首页>文档>其他文档>利用post推送文章至百度

此组别内的文章

需要支持?

如果通过文档没办法解决您的问题,请提交工单获取我们的支持!

利用post推送文章至百度

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

<?header('Content-Type:text/html;charset=utf-8');$xmldata =file_get_contents("https://xxx/sitemap.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("",$url),   CURLOPT_HTTPHEADER => array('Content-Type:text/plain'),);curl_setopt_array($ch, $options);$result =curl_exec($ch);echo $result;

使用

微信域名+/post.php

代码中推送地址及sitemap地址自行修改

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧