Issue
After a thorough search on facebook, api and fql keywords I found how to get facebook friends count but being a newbie and limited knowledge of php, i am struggling with the php syntax.
https://graph.facebook.com/fql?q=SELECT friend_count FROM user WHERE uid = xxxxx this gives me the count of fb friends
I have a php file that opens when I click on a link. What I want to do here is check count of friends in facebook and if the count is more than 25 then only open the page else show an alert message box "You should have atleast 25 friends to view the content"
Can someone help me with the php syntax?
Thank you in anticipation
Solution
You shouldn't use FQL as it will eventually be depreciated. You can use the taggable_friends API to get a list of friends and indirectly get a estimated friend count. The following tutorial explains the process.
PHP Code:
// get taggable friends
$taggable = (new FacebookRequest( $session, 'GET', '/me/taggable_friends' ))->execute()->getGraphObject()->asArray();
// output response
echo '<pre>' . print_r( $taggable, 1 ) . '</pre>';
// output total friends
echo count( $taggable['data'] );
Answered By - Niraj Shah
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.