小弟有一个php的站,本来程序没有rss自动ping百度的功能,但是我想加一个,于是从网上找了段代码如下:
php code
然后....就没有然后了...
想问下各位大大,怎样才能最终实现这个rss自动ping百度?求详细步骤,小弟是php菜鸟!
------解决方案--------------------
php codefunction posturl($url, $postvar){ $ch = curl_init(); $headers = array( post .$url. http/1.0, content-type: text/xml; charset=\”utf-8\, accept: text/xml, content-length: .strlen($postvar), ); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer,1); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_postfields, $postvar); $res = curl_exec ($ch); curl_close ($ch); return $res;}$url = ''; //不知道这个值是什么$baiduxml = weblogupdates.extendedping$url$url;echo $res = posturl('http://ping.baidu.com/ping/rpc2', $baiduxml);
