Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook extended access token doesn't work - but everything seems to be fine (?)
    primarykey
    data
    text
    <p>I try to get 60 days facebook access token from server side request. After user is loged in I check access token through getAccessToken() function from Facebook SDK and after that I use getExtendedAccessToken() which I found somewhere here: <a href="https://stackoverflow.com/questions/8982025/how-to-extend-access-token-validity-since-offline-access-deprecation">How to extend access token validity since offline_access deprecation</a> to ask for 60 days access token:</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'), $params = array( 'client_id' =&gt; $this-&gt;getAppId(), 'client_secret' =&gt; $this-&gt;getApiSecret(), '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> <p>Unfortunanely it still won't work my access token expired after 2 hours so I tried also this:</p> <pre><code> public function getSimpleExtendedAccessToken(){ $request = 'https://graph.facebook.com/oauth/access_token? client_id='. $this-&gt;getAppId(). '&amp;client_secret=' .$this-&gt;getApiSecret(). '&amp;grant_type=fb_exchange_token &amp;fb_exchange_token=' .$this-&gt;getAccessToken(); $response = file_get_contents($request); $params = null; parse_str($response, $params); return $params['access_token']; } </code></pre> <p>and this one also expired after 2 hours. But when I checked what was inside the array <code>$params</code> in the second function there was written:</p> <blockquote> <p>Array ( [access_token] => AAAFM5sO7[...] [expires] => 4897 )</p> </blockquote> <p>(That part: "<code>AAAFM5sO7[...]</code>" is of course my access token number)</p> <p>All access tokens which I received are the same: first one from <code>getAccessToken()</code>, second one from <code>getExtendedAccessToken()</code> and third one from <code>getSimpleExtendedAccessToken()</code>. </p> <p>Of course when I ask addtionaly more and more for extended access token the expiration number doesn't renew but it's counting down, and that is correct from the point of view of the Facebook documentation, because you can't ask for new access token each minute, but why I can't get 60 days access token?</p> <p>Can anyone help me because I'm a bit cofused?</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.
 

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