Is there a simple PHP or Javascript method of getting the total number of FaceBook friends? Twitter makes it super easy to do that, and I need to do the same for one of my WordPress installs.
Leave a Reply
You must be logged in to post a comment.
Is there a simple PHP or Javascript method of getting the total number of FaceBook friends? Twitter makes it super easy to do that, and I need to do the same for one of my WordPress installs.
You must be logged in to post a comment.
To get your friends as a JSON object from Facebook, you can use their Graph API. Easiest way is to visit this page:
http://developers.facebook.com/docs/reference/api/user/
Scroll down until you find the Friends link in the “Connections” table. That link will give you a JSON object containing all your friends. Note that the URL on that page is unique to you and contains your access token. Don’t share the link.
You can use this sort of code in WP to get and use that information:
You’ll want to use transients or something similar to cache the data so that you don’t ask FB for it all the time.
yes facebook does have a way for you to do that.
you can use the facebook graph api and its user|friend connection
something like this:
first create an application at
http://www.facebook.com/developers/
you might need to add the developer
application to your profile and you
will see a button “Set Up New App”.
then download this facebook php
wrapper from here
https://github.com/facebook/php-sdk/blob/master/src/facebook.php
and then you can work with this PHP code:
enjoy!
You can get friend count by fql easily.
There is a friend_count field against the user table that you can query.
There are lot of way to count the no of friends using Facebook Graph API with Php SDK, out of one i am telling..