How to Count All Your Facebook Friends using Facebook Garph API with PHP SDK?
Hello and welcome on the Facebook Graph API with PHP SDK Tutorial blog, On this blog i will teach you how to access the facebook app user's info in your custom app with Facebook Graph API using PHP SDK like User's Name, Profile Pic, Latest Post, Likes etc.
In this tutorial i will tell you how to count all friends and display the final count on your app, here is a simple code to access all friends and then count them and display the final count...
The below example is a complete code to access your all friends and count them...
$app_id, 'secret' => $app_secret, 'cookie' => true )); $user = $fb->getUser(); $loginUrl = $fb->getLoginUrl(array ( 'scope' => 'email' ) ); if ($user) { try { $fbuser=$fb->api('/me/friends'); $access_token = $fb->getAccessToken(); } catch (FacebookApiException $e) { echo $e; $user = null; } } if (!$user) { echo "<script type="text/javascript">top.location.href = '$loginUrl';</script>"; exit; } $friend_count=0; foreach($fbuser['data'] as $friends) { $friends_count++; } echo "You have Total ".$friend_count." Friends on Facebook"; ?>
Now copy the above code and paste it to your app and get the all friends count in your app...
Learn Facebook App Development Free
Hello there, You’ve done an incredible job. I will certainly digg it and personally suggest to my friends. I’m sure they will be benefited from this web site.
ReplyDeleteVery interesting blog. A lot of blogs I see these days don't really provide anything that attract others, but I'm most definitely interested in this one. Just thought that I would post and let you know.
ReplyDeleteThanks…:)Just desire to say your article is as astounding. The clarity in your post is simply cool and i could assume you are an expert on this subject. Well with your permission let me to grab your feed to keep updated with forthcoming post. Thanks a million and please continue the rewarding work.
ReplyDeleteI will probably be back again to browse much more, many thanks for the data.
ReplyDeleteWhat you're saying is completely true. I know that everybody must say the same thing, but I just think that you put it in a way that everyone can understand. I also love the images you put in here. They fit so well with what you're trying to say. I'm sure you'll reach so many people.
ReplyDeleteVery great post. I simply stumbled upon your blog and wanted to say that I have really enjoyed browsing your weblog posts. After all I’ll be subscribing on your feed and I am hoping you write again very soon!
ReplyDelete