Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should start with <a href="http://developers.facebook.com/docs/reference/php/">Facebook PHP SDK</a> , the key is to understand server-side login flow, as explained <a href="http://developers.facebook.com/docs/concepts/login/login-architecture/">here</a>, you can use this example as a start:</p> <pre><code>require 'facebook.php'; $facebook = new Facebook(array( 'appId' =&gt; 'YOUR_APP_ID', 'secret' =&gt; 'YOU_APP_SECRET', )); // Get User ID $user = $facebook-&gt;getUser(); // We may or may not have this data based on whether the user is logged in. // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook-&gt;api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook-&gt;getLogoutUrl(); } else { $loginUrl = $facebook-&gt;getLoginUrl(array("scope" =&gt; "user_photos")); } ?&gt; &lt;!doctype html&gt; &lt;html xmlns:fb="http://www.facebook.com/2008/fbml"&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php if ($user): ?&gt; &lt;a href="&lt;?php echo $logoutUrl; ?&gt;"&gt;Logout&lt;/a&gt; &lt;?php else: ?&gt; &lt;div&gt; &lt;a href="&lt;?php echo $loginUrl; ?&gt;"&gt;Login with Facebook&lt;/a&gt; &lt;/div&gt; &lt;?php endif ?&gt; &lt;h3&gt;PHP Session&lt;/h3&gt; &lt;pre&gt;&lt;?php print_r($_SESSION); ?&gt;&lt;/pre&gt; &lt;?php if ($user): ?&gt; &lt;h3&gt;You&lt;/h3&gt; &lt;img src="https://graph.facebook.com/&lt;?php echo $user; ?&gt;/picture"&gt; &lt;h3&gt;Your User Object (/me)&lt;/h3&gt; &lt;pre&gt;&lt;?php print_r($user_profile); ?&gt;&lt;/pre&gt; &lt;?php else: ?&gt; &lt;strong&gt;&lt;em&gt;You are not Connected.&lt;/em&gt;&lt;/strong&gt; &lt;?php endif ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload