Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To answer your question about detecting the dialog response with PHP SDK:</p> <p>The problem is that getloginURL only takes one URL parameter that it uses on success or error. I needed to detect if the user clicked OK or Cancel on the permissions dialog, so I could either redirect to a pre-permissions dialog page, or show the correct logged-in content.</p> <p>All I did was check if 'error_reason' existed in the url parameters, and if the error was 'user_denied', and took appropriate action. There might be a better way, but this worked for me.</p> <pre><code>&lt;?php //Facebook Authentication $user = $facebook-&gt;getUser(); //Get Login URL $loginUrl = $facebook-&gt;getLoginUrl(); //User is logged in 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; } } //User is not logged in if (!$user) { //Check if error_reason was generated and if the user denied login if (isset($_REQUEST['error_reason']) &amp;&amp; ($_REQUEST['error_reason']=='user_denied')) { //user cancelled permissions dialog thus not logged in to app, redirect elsewhere echo "&lt;script type='text/javascript'&gt;top.location.href = 'YOUR REDIRECT URL';&lt;/script&gt;"; exit; } else { //user not logged in so initiate permissions dialog echo "&lt;script type='text/javascript'&gt;top.location.href = '$loginUrl';&lt;/script&gt;"; exit; } } //get user basic description $userInfo = $facebook-&gt;api("/$user"); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    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