yiyunet 发表于 2013-11-22 09:24
不会用pubhubsubbub。有实践的来点介绍吧 - function http_post($url, $post_string) {
- $options = array(CURLOPT_URL => $url,
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $post_string,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_USERAGENT => "PubSubHubbub-Publisher-PHP/1.0");
- $ch = curl_init();
- curl_setopt_array($ch, $options);
- $response = curl_exec($ch);
- $info = curl_getinfo($ch);
- curl_close($ch);
- // all good
- if ($info['http_code'] == 204)
- return true;
- return false;
- }
- function Publisher($topic_url){
- $hub_urls=array('http://pubsubhubbub.appspot.com/','http://pubsubhubbub.superfeedr.com/','http://superfeedr.com/hubbub');
- $post_string = "hub.mode=publish";
- $post_string .= "&hub.url=".urlencode($topic_url);
- foreach ($hub_urls as $hub_url) {
- http_post($hub_url,$post_string);
- }
- }
复制代码 以前从wp插件中扣的代码,3个pub源
|