6 Eylül 2011 Salı

Twitter takipçi sayısını metin olarak gösterme



Twitter’daki takipçi sayınızı sitenizde metin olarak gösterebilirsiniz. Bunun için aşağıdaki kodufuctions.php dosyanıza ekleyin.



// Twitter sayi
function get_twitter_followers($username)
{
require_once(ABSPATH . 'wp-includes/class-snoopy.php');
$twitter = get_option("twitterfollowers");
$api = "http://twitter.com/statuses/user_timeline/".$username.".json?count=1";
 
if ($twitter['lastcheck'] < ( mktime() - 60 ) )
{
$snoopy = new Snoopy;
$result = $snoopy->fetch($api);
 
if ($result)
{
$data = json_decode($snoopy->results,true);
$twitter['followers'] = $data[0]['user']['followers_count'];
update_option('twitterfollowers',$twitter);
}
}
 
return $twitter['followers'];
}

Ardından aşağıdaki kodu takipçi sayısını göstermek istediğiniz yere ekleyin.



<?php echo  get_twitter_followers("twitter_id"); ?>

twitter_id yazan yere kendi kullanıcı adınızı girin. Hepsi bu kadar.

Hiç yorum yok:

Yorum Gönder