Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I used this code for the authentication.</p> <pre><code>&lt;?php $app_id = 'API_ID'; $app_sec = 'SECRETE'; $canvas_page = 'CANVAS_URL'; $scope = '&amp;scope=user_photos,email,publish_stream'; $auth_url = "http://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&amp;redirect_uri=" . urlencode($canvas_page).$scope; $signed_request = $_REQUEST["signed_request"]; list($encoded_sig, $payload) = explode('.', $signed_request, 2); $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true); if (empty($data["user_id"])) { echo("&lt;fb:redirect url='".$auth_url."' /&gt;"); } $access_token = $data['oauth_token']; $user_id = $data["user_id"]; $user = json_decode(file_get_contents( 'https://graph.facebook.com/me?access_token=' . $access_token)); function get_facebook_cookie($app_id, $application_secret) { $args = array(); parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args); ksort($args); $payload = ''; foreach ($args as $key =&gt; $value) { if ($key != 'sig') { $payload .= $key . '=' . $value; } } if (md5($payload . $application_secret) != $args['sig']) { return null; } return $args; } $cookie = get_facebook_cookie($app_id, $app_sec); //facebook application //set facebook application id, secret key and api key here $fbconfig['appid' ] = "APP_ID"; $fbconfig['api' ] = "API"; $fbconfig['secret'] = "SECRETE"; //set application urls here $fbconfig['baseUrl'] = "BASE_URL"; $fbconfig['appBaseUrl'] = "APP_BASE_URL"; $uid= null; //facebook user id try{ require_once "facebook.php"; } catch(Exception $o){ echo '&lt;pre&gt;'; print_r($o); echo '&lt;/pre&gt;'; } // Create our Application instance. $facebook = new Facebook(array( 'appId' =&gt; $fbconfig['appid'], 'secret' =&gt; $fbconfig['secret'], 'cookie' =&gt; true, )); ?&gt; </code></pre> <p>To publish to the wall</p> <pre><code>require_once 'authentication.php'; require_once "facebook.php"; $attachment = array('message' =&gt; 'some message', 'name' =&gt; 'name', 'caption' =&gt; "caption", 'link' =&gt; 'http://example.com/', 'description' =&gt; 'description', 'actions' =&gt; array(array('name' =&gt; 'name', 'link' =&gt; 'http://example.com/')) ); $result = $facebook-&gt;api('/me/feed?access_token='.$access_token, 'post', $attachment); </code></pre>
 

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