Twitter ve FeedBurner Count
Wordpress sayfalarında Twitter takipçi sayısını ve Feedburner takipçi sayısını gösteren bir script buldum bu sayfada. İlerde kullanmak üzere arşive eklemek istedim. Belki ihtiyaç duyan olur buna.
Öncellikle, functions.php dosyasına bazı kodlar eklememiz gerekiyor. Tabi bunun için öncellikle bir adet Twitter ve bir adet de Feedburner hesabına ihtiyacımız var. Eğer Zaten hesabınız varsa, aşağıdaki kodu functions.php dosyasına ekliyoruz.
// *** Feed ve Twitter takipçi sayısı ***
// cURL server üzerinde aktif olmalı
function curl($url) {
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_HEADER, 0);
// Domain adresini düzenle:
curl_setopt($ch,CURLOPT_USERAGENT,"fadonet.net");
curl_setopt($ch,CURLOPT_TIMEOUT,10);
$data = curl_exec($ch);
if (curl_errno($ch) !== 0 || curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200) {
$data === false;
}
curl_close($ch);
return $data;
}
// Feedburner takipçi sayısını düzenle
add_option('myfeeds_count','0','','yes');
add_option('myfeeds_api_timer',mktime() - 10000,'','yes');
function myfeeds_count() {
$rsscount = get_option('myfeeds_count');
if ( get_option('myfeeds_api_timer') < (mktime() - 3600) ) {
// Feedburner Hesap ayarlarını düzenle:
$fb_id = "http://feeds.feedburner.com/fadonet/posts";
$subscribers = curl("https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=http://feeds.feedburner.com/fadonet/posts");
try {
$xml = new SimpleXmlElement($subscribers, LIBXML_NOCDATA);
if ($xml) {
$rsscount = (string) $xml->feed->entry['circulation'];
update_option('myfeeds_count', $rsscount);
}
} catch (Exception $e) { }
update_option('myfeeds_api_timer', mktime());
}
// Sayıyı Ver
if($rsscount == 'N/A' || $rsscount == '0') { echo '<strong>Bi sürü takipçi</strong>'; } // z. B. wenn FeedBurner Schluckauf hat
else { echo $rsscount; }
}
// Twitter takipçi sayısını düzenle
add_option('mytwitter_followers','0','','yes');
add_option('mytwitter_api_timer',mktime() - 10000,'','yes');
function mytwitter_followers() {
$twittercount = get_option('mytwitter_followers');
if ( get_option('mytwitter_api_timer') < (mktime() - 3600) ) {
// Twitter Hesap ayarlarını düzenle:
$twitter_id = "fadonet";
$followers = curl("http://twitter.com/users/show.xml?screen_name=" . $twitter_id);
try {
$xml = new SimpleXmlElement($followers, LIBXML_NOCDATA);
if ($xml) {
$twittercount = (string) $xml->followers_count;
update_option('mytwitter_followers', $twittercount);
}
} catch (Exception $e) { }
update_option('mytwitter_api_timer', mktime());
}
if ( $twittercount != '0' ) { echo $twittercount; }
else { echo "<strong>growing number of</strong>"; }
}
Takipçi sayısını herhangi bir yerde göstermek isteyebilirsiniz. Bunun için:
Feedburner - <strong><?php if (function_exists('myfeeds_count')) myfeeds_count(); ?></strong> takipçi.
Twitter - <strong><?php if (function_exists('mytwitter_followers')) mytwitter_followers(); ?></strong>takipçi.
kodunu ekliyoruz. Hepsi bu kadar. Peki bunu yapmanın başka yolları yok mu? Tabi ki var. Feedburner hesap sayfasından Publicize ve ordan da FeedCount seçip ekleyebiliriz. Twitter için de http://twittercounter.com/ sayfasından yine aynı şekilde kod alıp ekleyebiliriz.

Henüz Yorum Yok!