Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>i'm not yet sure but i think i have the answer to the process of authorizing / authenticating a facebook app...</p> <p>step 1 : the first time a user access your app facebook sends you a signed request and you need to parse it validate it and check if the <code>$data['user_id']</code> is set.</p> <p>the code:</p> <pre><code> $data = $canvas-&gt;parse_signed_request($signed_request); $auth_url = 'http://www.facebook.com/dialog/oauth?client_id=' . $app_id . '&amp;redirect_uri=' . urlencode($canvas_page); if(empty($data['user_id'])) { echo '&lt;script&gt;top.location.href="' . $auth_url . '"&lt;/script&gt;'; } </code></pre> <p>so if the <code>$data['user_id']</code> is empty go authenticate.</p> <p>step 2: the user authorizes your app facebook sends you a signed request and a code</p> <pre><code> if(isset($_REQUEST['code'])) { $access_token = $canvas-&gt;get_access_token($_REQUEST['code']); $user = $canvas-&gt;getUser($access_token); $user_info = array( 'user_id' =&gt; $user-&gt;id, 'user_username' =&gt; $user-&gt;username, 'user_name' =&gt; $user-&gt;name ); // install the application for the new user. $user_obj = new User($user_info); // registered or allready exists. if($user_obj) { echo '&lt;script&gt;top.location.href="' . $canvas-&gt;canvas_page . '";&lt;/script&gt;'; } exit(); } </code></pre> <p>so from what i understood facebook sends you <code>$_REQUEST['code']</code> just one time: when the user approves your canvas application.</p> <p>that's it the user is installed so now every time a user re enters your application you will get a signed_request but this time because the user already approves the application the signed request will include an user_id and oauth_token with it u can get stuff from the graph api.</p> <p>IF THE SIGNED_REQUEST HAVE A USER_ID THIS IS WHAT U DO.</p> <pre><code> if(isset($data['user_id'])) { $user = false; if(!$user) { $user = $canvas-&gt;getUser($data['oauth_token']); } if(!ob_start('ob_gzhandler')) ob_start(); $styles = array( 'reset.css', 'jplayer.fbcanvas.css', 'fbcanvas.css' ); $scripts = array( 'http://connect.facebook.net/en_US/all.js#xfbml=1', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js', '/sources/js/jplayer/jquery.transform.js', '/sources/js/jplayer/jquery.grab.js', '/sources/js/jplayer/jquery.jplayer.js', '/sources/js/jplayer/mod.csstransforms.min.js', '/sources/js/jplayer/circle.player.js', '/sources/js/fbcanvas.js' ); $results = $canvas-&gt;getLatestSongs(); // the canvas. $page-&gt;set_title('Khawa'); $page-&gt;set_styles($styles); $page-&gt;set_scripts($scripts); $page-&gt;start_page(); require($_SERVER['DOCUMENT_ROOT'] . '/fbcanvas/fb.tpl'); $page-&gt;end_page(); ob_end_flush(); } </code></pre> <p>again i'm not sure but i think this is the process of authentication for FACEBOOK CANVAS APPS.</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.
    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