How to Get Facebook Friend Profile Randomly using Facebook Graph API, Choosing Facebook Friend Randomly
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....
No comments:
Post a Comment