Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook asking for permissions and authentication
    primarykey
    data
    text
    <p>I am currently making a facebook app and am having some problems with permissions. I need permission from each user to use there location and there friends locations. The code I have has worked in the past but recently seems to have stopped working. Assume my app_id and app_namespace are declared. All that happens is I am redirected to the dialog_url in the if(empty($code)) block, but to my knowledge $code should not be empty. Any help would be greatly appreciated. Thanks.</p> <pre><code>require_once('sdk/src/facebook.php'); require_once('AppInfo.php'); require_once('utils.php'); require_once('connection.php'); $facebook = new Facebook(array( 'appId' =&gt; AppInfo::appID(), 'secret' =&gt; AppInfo::appSecret(), )); $user_id = $facebook-&gt;getUser(); if(user has ran the app before) { mysql_close($connection); session_start(); $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection $dialog_url = "http://www.facebook.com/dialog/oauth?client_id" . $app_id . "&amp;redirect_uri=" . urlencode($my_url2) . "&amp;state=" . $_SESSION['state']; echo("&lt;script&gt; top.location.href='" . $dialog_url . "'&lt;/script&gt;"); } else { mysql_close($connection); session_start(); $code = $_REQUEST["code"]; if(empty($code)) { $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection $dialog_url = "http://www.facebook.com/dialog/oauth?client_id" . $app_id . "&amp;redirect_uri=" . urlencode($my_url) . "&amp;scope= user_location, friends_location, offline_access" . "&amp;state=" . $_SESSION['state']; echo("&lt;script&gt; top.location.href='" . $dialog_url . "'&lt;/script&gt;"); } if($_REQUEST['state'] == $_SESSION['state']) { $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $app_id . "&amp;redirect_uri=" . urlencode($my_url) . "&amp;client_secret=" . $app_secret . "&amp;code=" . $code; $response = @file_get_contents($token_url); $params = null; parse_str($response, $params); $graph_url = "https://graph.facebook.com/me?access_token" . $params['access_token']; $user = json_decode(file_get_contents($graph_url)); echo("Hello " . $user-&gt;name); } else { echo("The state does not match. You may be a victim of CSRF."); } } </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. 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