0

I am the administrator of a Facebook page which needs to have an age restriction of 17+ on it. On my website, I am making some Graph API queries, like querying photo albums and linking to them on Facebook. I am using the PHP Facebook API.

I can't seem to get to grips around the page access tokens and when they expire and when not. I tried to follow this answer here, which was highly voted, but it isn't clear what you do with the first access_token after you copy it. I am not sure if this is even valid any more.

I tried to access the page using the access token I get when I do me/accounts in Graph Explorer and it works, but after some time it expires and I get an exception that the token expired. I need something that stays working and doesn't expire and need me to go in and update it.

This is the code I have so far:

$fbconfig = array();
$fbconfig['appId'] = DEF_APP_ID;
$fbconfig['secret'] = DEF_APP_SECRET;
$fbconfig['fileUpload'] = false; 

Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;

$facebook = new Facebook($fbconfig);

//I am not sure if the following is the right way
$facebook->setAccessToken(DEF_ACCESS_TOKEN);  
$facebook->setExtendedAccessToken();

...

try
{
    $albums_resp = $facebook->api('/'.$id.'/albums','GET'); 
    ...
}
catch (FacebookApiException $ex)
{
    error_log($ex); 
}

What is the right way to achieve this?

Community
  • 1
  • 1
jbx
  • 21,365
  • 18
  • 90
  • 144
  • possible duplicate of [facebook: permanent Page Access Token?](http://stackoverflow.com/questions/17197970/facebook-permanent-page-access-token) – rjdown Nov 19 '14 at 01:42
  • @rjdown Those instructions aren't even valid any more. – jbx Nov 19 '14 at 01:53
  • No I am not. Step 2 and 3 aren't even possible, they aren't there any more in the app settings. – jbx Nov 19 '14 at 02:25
  • 1
    Yes, they are. Add a website as per the docs that you should probably read – rjdown Nov 19 '14 at 02:58
  • I already have an app, and it has the site URL in it. There is nowhere that says 'Website with Facebook Login' on the settings page. Could be I am already past step 2, if the URL is the only thing I need. Step 3 says 'still in settings go to Permissions'. There is no Permissions link anywhere in the settings screen, I checked the Basic and Advanced tabs. I tried to follow the (utterly confusing) instructions here https://developers.facebook.com/docs/facebook-login/access-tokens, but I just got tokens that expire after I log out or after an hour or so. Maybe I am doing something wrong in PHP. – jbx Nov 19 '14 at 14:38

0 Answers0