Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can do it via exception handling. If your access token is expired or it is invalid it will throw you an error and give you below mentioned message. </p> <pre><code>public function getUserInfo($access_token) { try { $user_info = $this-&gt;facebook-&gt;api( '/me', 'GET', array('access_token' =&gt;$access_token) ); } catch(Exception $e){ $message = $e-&gt;getMessage(); if ((strpos($message, 'Error validating access token') !== false) || (strpos($message, 'Invalid OAuth access token') !== false) || (strpos($message, 'An active access token must be used') !== false) ) { echo 'Your custom Message'; } } } </code></pre> <p>You can pass your access token in to your function and than you check do like above exception handling.</p> <p>Hope it helps you.</p> <p>By this way you can get extended access token</p> <pre><code> /** * Getting User Acess Tocken , extended it and save it in to database...... */ public function getAccessToken($user_id,$fb_account_id) { $access_token=$this-&gt;facebook-&gt;getAccessToken(); $extended_access_token=$this-&gt;getExtendedAccessToken($access_token); /** * To save Access tocken and other necessary option */ $usr_bus_model = new Application_Model_UserBusinessAccounts; $usr_bus_model-&gt;loadAccount($user_id,'Facebook',(int)$fb_account_id,false); $usr_bus_model-&gt;details=$extended_access_token; if(!empty($extended_access_token)) { $usr_bus_model-&gt;status= 'active'; } $usr_bus_model-&gt;save(); return $extended_access_token; } public function getExtendedAccessToken($access_token) { $token_url="https://graph.facebook.com/oauth/access_token"; $params=array('client_id'=&gt;self :: appId,'client_secret'=&gt;self :: appSecretId,'grant_type'=&gt;'fb_exchange_token','fb_exchange_token'=&gt;$access_token); $response = $this-&gt;curl($token_url,$params); $response = explode ('=',$response); $response = explode ('&amp;',$response[1]); $response = $response[0]; return $response; } </code></pre> <p>I've made above two function. So whenever you need to use access token just call the extended access token also and save this in to your db. So Your access token will never expire.</p>
 

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