代码如下:
<?php header('Content-Type:text/html;charset=utf-8'); $xmldata =file_get_contents("http://你的域名/sitemap.xml");//molure.cn $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 ='百度站长的推送接口';//molure.cn $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; ?>成功会返回
{"remain": 今日剩余数,"success": 推送成功数} 的。
发表评论