Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need several things to update your facebook profile or a page's feed: a facebook application (<strong>client_id</strong>, <strong>client_secret</strong>), <strong>profile_id</strong>, and <strong>access_token</strong> (publish_stream, manage_pages, offline_access permissions)</p> <p>You need offline_access because if not, then the access token will expire. If you've read that you don't need offline_access if you already have publish_stream specified, they just meant that you don't need it always.</p> <p>To publish a post is easy:</p> <pre><code>$data = array( 'access_token' =&gt; $access_token, 'message' =&gt; 'status message', ); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/{$profile_id}/feed"); </code></pre> <p>Now how to get the <strong>profile_id</strong> and <strong>access_token</strong>, you can use my app <a href="http://codecri.me/projects/post-panda/" rel="nofollow">post panda</a>, or make your own script. I'll include it here:</p> <pre><code># arvin castro # http://codecri.me/ # January 16, 2011 $client_id = ''; # application id $client_secret = ''; # application secret $callbackURL = 'http://'; # the URL of this script $extendedPermissions = 'publish_stream,manage_pages,offline_access'; session_name('facebookoauth'); session_start(); if(isset($_GET['logout']) and $_SESSION['loggedin']) { $_SESSION = array(); session_destroy(); } if(isset($_GET['signin'])) { # STEP 1: Redirect user to Facebook, to grant permission for our application $url = 'https://graph.facebook.com/oauth/authorize?' . xhttp::toQueryString(array( 'client_id' =&gt; $client_id, 'redirect_uri' =&gt; $callbackURL, 'scope' =&gt; $extendedPermissions, )); header("Location: $url", 303); die(); } if(isset($_GET['code'])) { # STEP 2: Exchange the code that we have for an access token $data = array(); $data['get'] = array( 'client_id' =&gt; $client_id, 'client_secret' =&gt; $client_secret, 'code' =&gt; $_GET['code'], 'redirect_uri' =&gt; $callbackURL, ); $response = xhttp::fetch('https://graph.facebook.com/oauth/access_token', $data); if($response['successful']) { $var = xhttp::toQueryArray($response['body']); $_SESSION['access_token'] = $var['access_token']; $_SESSION['loggedin'] = true; } else { print_r($response['body']); } } if($_SESSION['loggedin']) { // Get Profile ID $data = array(); $data['get'] = array( 'access_token' =&gt; $_SESSION['access_token'], 'fields' =&gt; 'id,name,accounts', ); $response = xhttp::fetch('https://graph.facebook.com/me', $data); echo '&lt;pre&gt;'; print_r(json_decode($response['body'], true)); echo '&lt;/pre&gt;'; } else { echo '&lt;a href="?signin"&gt;Sign in with Facebook&lt;/a&gt;'; } ?&gt; </code></pre> <p>I'm using my cURL wrapper class, <a href="http://codecri.me/sources/includes/class-xhttp-php/" rel="nofollow">xhttp</a></p>
    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. VO
      singulars
      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