How to Display a Facebook Friend Profile Randomly using Facebook Graph API
Hi welcome again friends with this new tutorial we have learn some topics before by previous tutorials and in this tutorial i will tell you how to choose a Facebook friend randomly and display his/her information in your app like his/her Name, Gender, Profile Pic, Last status update, likes etc. so lets begin with this new tutorial ...
Here is a simple code to access the Facebook Friend randomly....
Hi welcome again friends with this new tutorial we have learn some topics before by previous tutorials and in this tutorial i will tell you how to choose a Facebook friend randomly and display his/her information in your app like his/her Name, Gender, Profile Pic, Last status update, likes etc. so lets begin with this new tutorial ...
Here is a simple code to access the Facebook Friend randomly....
<html> <body> <?php $app_id = "YOUR APP ID"; $app_secret = "YOUR APP SECRET"; try { include_once ('libs/facebook.php'); } catch(Exception $o) { print_r($o); } $fb = new Facebook(array( 'appId' => $app_id, 'secret' => $app_secret, 'secret' => $app_secret, 'cookie' => true )); $user = $fb->getUser(); $loginUrl = $fb->getLoginUrl(array ( 'scope' => 'email' ) ); if ($user) { try { $fbfriends=$fb->api('/me/friends?fields=picture.width(60).height(50),name,gender'); $access_token = $fb->getAccessToken(); } catch (FacebookApiException $e) { echo $e; $user = null; } } if (!$user) { echo "<script type="text/javascript">top.location.href = '$loginUrl';</script>"; exit; } $name;$pics;$index=0; foreach($fbfriends['data'] as $frnd) { $pics[$index]=$frnd['picture']['data']['url']; $name[$index]=$frnd['name']; $index++; } $rand_pics = array_rand($pics, 2); $p=$pics[$rand_pics[0]]; $rand_names = array_rand($name, 2); $n=$name[$rand_names[0]]; echo $n." "."<img src="".$p."" />"; ?> </body> </html>
The above code is genuine and it is 100% tested if you want to develop an app in which you want to show the app user's friends randomly then just copy the above code and paste it to your app code and change the APP ID and APP SECRET according to your app....
For more tutorials on Facebook App development visit the below link...
Facebook Apps Tutor free
I have been browsing internet for more than three hours today since morning, yet I didn’t found any interesting article like this which provides knowledge.
ReplyDeleteAwakening post to read on and it creates a common sense among computer users to save their money from unnecessary paying for a anti virus software.
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.
ReplyDelete