使用Getu Transient和Wpu Remoteu Get获取Feedburner计数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用Getu Transient和Wpu Remoteu Get获取Feedburner计数相关的知识,希望对你有一定的参考价值。
function feed_subscribers(){ $feed_url = 'http://feeds.feedburner.com/yourname'; $count = get_transient('feed_count'); if ($count != false) return $count; $count = 0; $data = wp_remote_get('http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri='.$feed_url.''); if (is_wp_error($data)) { return 'error'; }else{ $body = wp_remote_retrieve_body($data); $xml = new SimpleXMLElement($body); $status = $xml->attributes(); if ($status == 'ok') { $count = $xml->feed->entry->attributes()->circulation; } else { $count = 300; // fallback number } } set_transient('feed_count', $count, 60*60*24); // 24 hour cache echo $count; } Then add this to your WordPress theme in the location you wish to display the RSS feed subscriber count. <? feed_subscribers(); ?>
以上是关于使用Getu Transient和Wpu Remoteu Get获取Feedburner计数的主要内容,如果未能解决你的问题,请参考以下文章