subscriber count ကို feed burner ကနေ ယူချင်တာနဲ့ API လေး စမ်းဖြစ်သွားတယ်။ feed burner api မလုပ်ခင် api ကို allow လုပ်ပေးဖို့လိုတယ်။
- login your feedburner and go to your feed.
- Go to Publicize tag
- Go to Awareness Api and active it.
code ကတော့ အောက်က အတိုင်းပဲ။ ဒါပေမယ့် uri ဆိုတဲ့နေရာမှာ ကိုယ့် uri လေး ထည့်ပေးဖို့လိုပါတယ်။
<?php
//get cool feedburner count
$toopen="http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=saturngod";
$ch = curl_init(); /// initialize a cURL session
curl_setopt($ch, CURLOPT_URL, $toopen );
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec ($ch);//end get cool feedburner count
curl_close($ch);
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->loadXML($content);
$count=$dom->getElementsByTagName("entry")->item(0)->getAttribute("circulation");
echo $count;
?>
Twitter ကတော့ တော်တော်လွယ်ပါ့။ screen_name မှာ twitter account name ထည့်လိုက်ရုံပဲ။
<?php
$toopen="http://twitter.com/users/show.xml?screen_name=saturngod ";
$ch = curl_init(); /// initialize a cURL session
curl_setopt($ch, CURLOPT_URL, $toopen );
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec ($ch);//end get cool feedburner count
curl_close($ch);
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->loadXML($content);
$count=$dom->getElementsByTagName("followers_count")->item(0)->nodeValue;
$twitt=$dom->getElementsByTagName("text")->item(0)->nodeValue;
?>

Leave a Reply