Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Full flow - four page example (easier to edit and understand for an example)</p> <p>So the config just has the basic app info...</p> <p>When you load <code>index.php</code> - it redirects to facebook to get authorization for the page.. (probably already have this.. but covering all bases)</p> <p>Facebook then redirects back to the redirecturl (<code>backfromfb.php</code>)...</p> <p>Facebook returns the access token as a hash and not a get variable, so this page refreshes with the hash as a variable...</p> <p>It then loads the <code>PageUpdate.php</code> which handles looping through the app/admin tokens and finds the correct one for the page you want to post to..</p> <p>Then it builds the post and submits it..</p> <p>It sounds like you have an understanding of most of this... So hopefully this will help you with that last bit.</p> <p><strong>config.php</strong></p> <pre class="lang-php prettyprint-override"><code>&lt;?php $config = array( 'appId' =&gt; 'YOUR APP ID', 'secret' =&gt; 'YOUR APP SECRET', 'cookie' =&gt; true; ); $baseurl = 'http://yoursite.com/'; $returnpage = 'backfromfb.php'; require_once('library/facebook.php'); ?&gt; </code></pre> <p><strong>index.php</strong></p> <pre class="lang-php prettyprint-override"><code>&lt;?php require_once('config.php'); ?&gt; &lt;html&gt;&lt;head&gt;&lt;title&gt;Redirecting for auth&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;script type="text/javascript"&gt; window.location.href = 'https://www.facebook.com/dialog/oauth?client_id=&lt;?php echo $config['appId']; ?&gt;&amp;redirect_uri=&lt;?php echo $baseurl . $returnpage; ?&gt;&amp;scope=manage_pages&amp;response_type=token'; &lt;/script&gt;&lt;/body&gt;&lt;/html&gt; </code></pre> <p><strong>backfromfb.php</strong></p> <pre class="lang-php prettyprint-override"><code>&lt;?php require_once('config.php'); // this page just passes the access token from the hash to a GET arg... if (!isset($_GET['access_token'])) { ?&gt; &lt;html&gt;&lt;head&gt;&lt;title&gt;Redirecting&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;script type="text/javascript"&gt; accessToken = window.location.hash.substring(1); window.location.href = '&lt;?php echo $baseurl . $returnpage; ?&gt;?' + accessToken; &lt;/script&gt;&lt;/body&gt;&lt;/html&gt; &lt;?php } else { require_once('PageUpdate.php'); } ?&gt; </code></pre> <p><strong>PageUpdate.php</strong></p> <pre class="lang-php prettyprint-override"><code>&lt;?php require_once('config.php'); $pageID = "123456 WHatever you page id is"; $AppToken = array( 'access_token' =&gt; $_REQUEST['acess_token'] ); $fb = new Facebook($config); // Load APP page access rights for user via AppToken $pageAdmin = $fb-&gt;api('/me/accounts', 'GET', $AppToken); // Find the page access token foreach ($pageAdmin['data'] as $data) { if ($data['id'] == $pageID) { $pageToken['access_token'] = $data['access_token']; continue; } } // compile the post $WallPost = array( 'message' =&gt; 'Test post from my app!' ); // you can also use 'picture', 'link', 'name', 'caption', 'description', 'source'.... //http://developers.facebook.com/docs/reference/api/ // post to wall $response = $fb-&gt;api($pageID . '/feed','POST',$WallPost); if($response) { echo 'Success!'; echo '&lt;pre&gt;' . $response . '&lt;/pre&gt;'; } else echo "failed"; ?&gt; </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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