当前位置:首页>默认>php代码使用post推送文章至百度

php代码使用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地址自行修改

一、本站上的部份代码及教程来源于互联网,仅供网友学习交流。如有侵权,无意侵害您的权益,请发送邮件至xutian#ahap.cn或点击右侧 联系我们,我们将尽快处理。
二、请勿将购买的资源教程转载或分享与他人!

给TA充电
共{{data.count}}人
人已充电
默认

wordpress自动设置第一张图为特色图片代码

2021-11-19 9:53:09

默认

B2 Pro 主题【社交类型菜单】

2021-11-24 23:26:30

2 条回复 A文章作者 M管理员
  1. 斯巴达

    除了b2好像其他主题不能使用


      Warning: Undefined array key 1 in /www/wwwroot/www.ahap.cn/wp-content/themes/b2_ahap/Modules/xmw-ability.php on line 456

      Warning: Undefined array key 1 in /www/wwwroot/www.ahap.cn/wp-content/themes/b2_ahap/Modules/xmw-ability.php on line 458

      Warning: Undefined array key 2 in /www/wwwroot/www.ahap.cn/wp-content/themes/b2_ahap/Modules/xmw-ability.php on line 458
    • AHAP

      WordPress都可以用,有XML都能用

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索