Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's also possible to use a combination of PHP SDK and JS SDK, with the latter performing the login and the former storing data on the server. Something like:</p> <pre class="lang-php prettyprint-override"><code>&lt;?php require_once 'config.php'; require_once 'lib/facebook.php'; $facebook = new Facebook(array( 'appId' =&gt; FB_APP_ID, 'secret' =&gt; FB_APP_SECRET, )); ?&gt; &lt;!DOCTYPE html&gt; &lt;html xmlns:fb="http://www.facebook.com/2008/fbml"&gt; &lt;body&gt; &lt;div id="fb-root"&gt;&lt;/div&gt; &lt;script&gt; window.fbAsyncInit = function () { FB.init({ appId:'&lt;?php echo $facebook-&gt;getAppID() ?&gt;', cookie:true, xfbml:true, oauth:true }); FB.Event.subscribe('auth.login', function (response) { window.location = "showUser.php"; //redirect to showUser.php on Login }); FB.Event.subscribe('auth.logout', function (response) { window.location.reload(); }); }; (function () { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); &lt;/script&gt; &lt;div class="fb-login-button" data-show-faces="true" data-width="200" data-max-rows="1"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And in <code>showUser.php</code> you have something like:</p> <pre class="lang-php prettyprint-override"><code>&lt;?php #showUser.php require_once 'config.php'; require_once 'lib/facebook.php'; $facebook = new Facebook(array( 'appId' =&gt; FB_APP_ID, 'secret' =&gt; FB_APP_SECRET, )); $user = $facebook-&gt;getUser(); if($user) { if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook-&gt;api('/me'); var_dump($user_profile); //You can now save this data } catch (FacebookApiException $e) { echo '&lt;pre&gt;'.htmlspecialchars(print_r($e, true)).'&lt;/pre&gt;'; $user = null; } } } ?&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. 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