Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with OAuth 2.0 in my Facebook application
    primarykey
    data
    text
    <p>evertything was running fine in my facebook application until I upgraded it to OAuth 2.0, and im not sure if im doing everything right.</p> <p>The thing is that I already made the OAuth dialog to work and when the user authorizes the app, it renders my app into the iFrame, but I am having trouble with my $_GETs[], let me explain:</p> <p>Here's my index.php, which I use as the main page, while i just include() some file in a div called content, depending on the $_GET['section']:</p> <pre><code> $app_id = "xxx"; $application_secret = 'xxx'; $canvas_page = "xxx"; $auth_url = "http://www.facebook.com/dialog/oauth?client_id=".$app_id. "&amp;redirect_uri=".urlencode($canvas_page)."&amp;scope=publish_stream,offline_access"; //OAuth 2.0 function parse_signed_request($signed_request, $secret) { list($encoded_sig, $payload) = explode('.', $signed_request, 2); // decode the data $sig = base64_url_decode($encoded_sig); $data = json_decode(base64_url_decode($payload), true); if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') { error_log('Unknown algorithm. Expected HMAC-SHA256'); return null; } // check sig $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true); if ($sig !== $expected_sig) { error_log('Bad Signed JSON signature!'); return null; } return $data; } function base64_url_decode($input) { return base64_decode(strtr($input, '-_', '+/')); } // $data = parse_signed_request($_REQUEST["signed_request"],$application_secret); if (empty($data["user_id"])) { echo("&lt;script&gt; top.location.href='" . $auth_url . "'&lt;/script&gt;"); } else { $_SESSION['on'] = 1; include ('src/facebook.php'); $files = array(); $files['RE'] = 'xxx.php'; $files['RC'] = 'yyy.php'; $files['DP'] = 'zzz.php'; $facebook = new Facebook(array( 'appId' =&gt; $app_id, 'secret' =&gt; $application_secret, 'cookie' =&gt; true, 'perms' =&gt; 'publish_stream, offline_access', )); $_SESSION["access_token"] = $data["oauth_token"]; $me = $facebook-&gt;api('/me?oauth_token='.$_SESSION["access_token"]); &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" xmlns:fb="https://www.facebook.com/2008/fbml"&gt; &lt;link rel="stylesheet" href="css/style.css" type="text/css"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt; &lt;meta http-equiv="Content-Style-Type" content="text/css"&gt; &lt;meta property="og:title" content="title" /&gt; &lt;meta property="og:description" content="description" /&gt; &lt;meta property="og:image" content="thumbnail_image" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="wrapper"&gt; &lt;?php include("inc/app_header.php");?&gt; &lt;div class="content"&gt; &lt;?php if(isset($_GET['section'])) { $file_to_include = 'inc/'.$files[$_GET['section']]; } else { $file_to_include = 'inc/section_restaurantes.php'; } include($file_to_include); ?&gt; &lt;div class="content_bottom_space"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="footer"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php } ?&gt; </code></pre> <p>and the code for section_restaurantes is:</p> <pre><code> &lt;div class="section_restaurantes"&gt; &lt;div class="restaurantes_container"&gt; &lt;div class="restaurantes"&gt;&lt;a href="index.php?section=DP"&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="restaurantes"&gt;&lt;a href="index.php?section=PH"&gt;&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The thing is that when I click in those divs all my browser is reloaded, the ?code= parameter in the url changes twice and it reloads again on section_restaurantes.php, instead of loading the DP section, I hope I'm clear.</p> <p>I think because its reloading twice i loose the $_GET['section'] parameter and then it loads the default which is "inc/section_restaurantes.php"</p> <p>I need help please, I've tried to find solutions on the internet but I found nothing.</p>
    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.
 

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