How to Access the App User Name and Profile Pic using Facebook Graph API with PHP
Hi welcome friends we are here for learning the Facebook Graph API to develop the Facebook applications. In previous tutorial we have learn how to create a Facebook Application...
Learn
Creating Your First Facebook App
In this Tutorial we will learn how to access the Facebook App user's name and profile picture using your Facebook App using Facebook Graph API with PHP sdk...
Here is a simple code to access the Facebook App User's Name and Profile Pic...
Hope you are understand this code and if you have any question regarding this code then you are free to ask ......
Learn
Creating Your First Facebook App
In this Tutorial we will learn how to access the Facebook App user's name and profile picture using your Facebook App using Facebook Graph API with PHP sdk...
Here is a simple code to access the Facebook App User's Name and Profile Pic...
<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); } $facebook = new Facebook(array( 'appId' => $app_id, 'secret' => $app_secret, 'cookie' => true )); $user = $facebook->getUser(); $loginUrl = $facebook->getLoginUrl(array ( 'scope' => 'email' ) ); if ($user) { try { $f=$facebook->api('/me'); $access_token = $facebook->getAccessToken(); } catch (FacebookApiException $e) { echo $e; $user = null; } } if (!$user) { echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>"; exit; } echo $f['name']."<br/><img src='https://graph.facebook.com/".$f['id']."/picture' width='50' height='50' />"; ?> </body> </html>
Hope you are understand this code and if you have any question regarding this code then you are free to ask ......
No comments:
Post a Comment