I'd like to include a within the footer of my website a "facebook fan count". I believe this will add an incentive to users considering clicking our facebook icon. "join XXXX fans on our facebook page" for example. I want the XXXX to be automatically populated with our fa开发者_C百科cebook fan count. I want to do the same with twitter. Any insight you can provide would be helpful.
Note, I dont want to include the whole FB widget, just need the fan count for this purpose.
Thanks
You can get the fan count of a page via their API using Pages.getInfo
found here.
Or using FQL:
select fan_count from page where page_id = [ID of Fan Page]
For Twitter you can get the followers_count from this call of users/lookup
found here.
Do the following FQL query to the facebook api:
select fan_count from page where page_id = <FAN_PAGE_ID>
For twitter you need to extract it from a user query.
https://graph.facebook.com/cocacola
"fan_count" property. replace "cocacola" with your page ID.
FaceBook Graph API
http://developers.facebook.com/docs/api#selection
the new Graph api should work for you..
Replace the "devilsworkshop.org" with your page name and then try opening page
https ://graph.facebook.com/devilsworkshop.org
It will return a object with fan_count as its member.
精彩评论