Q: facebook extending the access token Hi I've seen the answer here 
http://facebook.stackoverflow.com/questions/8982025/how-to-extend-access-token-validity-since-offline-access-deprecation
and gave it a go but I'm having trouble getting it to work.
I have an expired token - but obviosuly just need a way to auto update it.
is this possible can someone slip me some code
At present I'm trying this
try {
$result = $facebook->api(
                '/me/permissions/',
                'get',
                array('access_token' => $token)
        );
}
catch(FacebookApiException $e) {

    echo "token invalid";
    $facebook->setAccessToken($token);
    echo $facebook->getExtendedAccessToken();
}

But I still get
token invalid{"error":{"message":"Error validating access token: Session has expired at unix time 1338858000. The current unix time is 1338985046.","type":"OAuthException","code":190,"error_subcode":463}}

Any help. Thanks
Richard

Hi thanks for your help I've got the extended stuff to work and I'm understanding a little more
- I have a followup question say my token becomes invalid - what to do then?
I'm still logged into facebook and I've given permission to my app so it's all there I just need a new key.
I've tried this
$facebook = new Facebook(array(
                'appId'  => FACEBOOKAPPID,
                'secret' => FACEBOOKSECRET,
                'cookie' => true,
            ));

$url = $facebook->getLoginUrl(array('canvas'=>1,'fbconnent'=>1,'scope'=>'offline_access,publish_stream,email,user_about_me,user_birthday,user_website'));
file_get_contents($url);
$fb_session = $facebook->getUser();
echo $fb_session.'<br />';

$token = $facebook->getExtendedAccessToken();           
echo $token.'<br />';

As it seems that you need to 'login' to facebook to get the details again but it seems that you can't use file_get_contents as facebook requires the cookie that is on your machine. I'm trying to do this on the fly so not to bother the user with any popups and also they have already given the app permission.
Any ideas?
Richard
Oh and just doing this doesn't seem to work either.
$facebook = new Facebook(array(
    'appId'  => $this->fbApiKey,
    'secret' => $this->fbSecretKey,
    'cookie' => true,
));
$token = $facebook->getAccessToken();


A: try this code
$facebook = new Facebook(array(
    'appId'  => $this->fbApiKey,
    'secret' => $this->fbSecretKey,
    'cookie' => true,
));
$token = $facebook->getAccessToken();


A: According to the Removal of offline_access permission:

Scenario 4: Client-side OAuth and Extending Access_Token Expiration Time through New Endpoint
Using the new endpoint below, you will be able to extend the
  expiration time of an existing, non-expired, short-lived user
  access_token. Please note, the endpoint can only be used to extend the
  short-lived user access_tokens. If you pass an access_token that had a
  long-lived expiration time, the endpoint will simply pass that same
  access_token back to you without altering or extending the expiration
  time

Once the long lived access token expires you'll need to get a new short lived token and then extend it.
As for "how to extend it", it's on the same post:
https://graph.facebook.com/oauth/access_token?             
    client_id=APP_ID&
    client_secret=APP_SECRET&
    grant_type=fb_exchange_token&
    fb_exchange_token=EXISTING_ACCESS_TOKEN

