Web 2.0 革命中我最喜欢的部分是丰富的 API。每个人都有一个:Digg、Feedburner、Pownce、Flickr、Google Maps 等。FeedBurner 提供了一个可爱的“Awareness API”,允许您从您的 FeedBurner 帐户中提取统计数据。以下是使用 PHP cURL 的方法。
PHP
//open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,'http://api.feedburner.com/awareness/1.0/GetFeedData?id=#######'); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); //execute post $content = curl_exec($ch); $subscribers = get_match('/circulation="(.*)"/isU',$content); echo 'Subscribers: '.$subscribers; //close connection curl_close($ch); /* helper: does the regex */ function get_match($regex,$content) { preg_match($regex,$content,$matches); return $matches[1]; }
就这么简单。更妙的是,我讨厌 FeedBurner 的“徽章”,而且我可以随心所欲地操纵上述代码的结果。单击此处了解有关 FeedBurner 的 Awareness API 以及您可以提取的有关您的 Feed 的信息的更多信息。