Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edit (August 14th 2012):</strong><br> A week ago the official Facebook PHP SDK was updated. The function name was changed to <em>setExtendedAccessToken</em>, and it was decided we actually needed to destroy the session afterwards, to remove the risk of having two active sessions.<br> Also, the function no longer actually returns the token, but instead stores it within the persistant data. You can therefore get the new access token with the public function <em>getAccessToken</em> afterwards. Grab the new SDK from <a href="https://github.com/facebook/facebook-php-sdk/">official Facebook PHP SDK github page</a> to make sure you're up to date.</p> <p><strong>Original Answer:</strong></p> <p>I have added a new public function to the base_facebook.php file, which returns an new access token which expires in 60 days. You can make a request to this function after you've received the normal access token. I've not tested, but I assume you also need to enable 'deprecate offline_access" in your Advanced settings of the Developer App.</p> <p>Just add this to your base_facebook.php inside the facebook class and make a call to it. It works for me.</p> <pre><code> public function getExtendedAccessToken(){ try { // need to circumvent json_decode by calling _oauthRequest // directly, since response isn't JSON format. $access_token_response = $this-&gt;_oauthRequest( $this-&gt;getUrl('graph', '/oauth/access_token'), array( 'client_id' =&gt; $this-&gt;getAppId(), 'client_secret' =&gt; $this-&gt;getAppSecret(), 'grant_type'=&gt;'fb_exchange_token', 'fb_exchange_token'=&gt;$this-&gt;getAccessToken() ) ); } catch (FacebookApiException $e) { // most likely that user very recently revoked authorization. // In any event, we don't have an access token, so say so. return false; } if (empty($access_token_response)) { return false; } $response_params = array(); parse_str($access_token_response, $response_params); if (!isset($response_params['access_token'])) { return false; } return $response_params['access_token']; } </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. 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