Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8060601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:02:48+00:00 2026-06-05T10:02:48+00:00

BASIC PROBLEM: I want my app to be able to make calls to the

  • 0

BASIC PROBLEM: I want my app to be able to make calls to the Facebook graph api about authorized users even while the user is away.

For example, I want the user (A) to authorize the app, then later I want user (B) to be able to use the app to view info about user (A)’s friends. Specifically: the “work” field. Yes, I am requesting those extended permissions (user_work_history, friends_work_history, etc). Currently my app has access to the logged-in user’s friends work history, but not to any of the friends’ work history of other users of the app.

Here’s what I know already:

  • Adding offline_access to the scope parameter is the old way and it
    no longer works.
  • The new way is with “long-lived” access tokens,
    described here. These last for 60 days.
  • I need to exchange a normal access token to get the new extended token. The FB documentation says:

    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

Here’s what I don’t know (and I’m hoping you can tell me):
How do I get the extended (aka “long-lived”) access token using the Facebook PHP SDK? Currently, my code looks like this:

$facebook->getAccessToken();

Is there such a thing as this?:

$facebook->getExtendedAccessToken();

If not, is this what I should be doing?

$accessToken = $facebook->getAccessToken();
$extendedAccessToken = file_get_contents("https://graph.facebook.com/oauth/access_token?             
    client_id={$appId}&
    client_secret={$secret}&
    grant_type=fb_exchange_token&
    fb_exchange_token={$accessToken}"
    );

I’ve tried it and it doesn’t work. I get this error:

Warning: file_get_contents(https://graph.facebook.com/oauth/access_token? client_id=#######& client_secret=#########& grant_type=fb_exchange_token& fb_exchange_token=##########) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /...

Does it work any differently if I switch to FQL instead of the graph api? I’ve read through the Facebook documentation many times, but the PHP sdk is not thoroughly documented and I can’t find any examples of how this should work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:02:49+00:00Added an answer on June 5, 2026 at 10:02 am

    I finally figured this out on my own. The answer is pretty anti-climactic. It appears that newly created apps get 60 day access tokens automatically. I’m not sure if this is dependent on enabling the “depricate offline_access” setting in the Migrations section of the app settings. Leave it on to be safe.

    So at the time of writing this, you can use the PHP SDK as follows: $facebook->getAccessToken();

    (The reason my app wasn’t working as expected was unrelated to the expiration of the access token.)

    Just one more thing, to get long-lived access token using PHP SDK you should call $facebook->setExtendedAccessToken(); before $facebook->getAccessToken();

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem The basic problem is I want to debug some 3rd party code to
I'm having a really basic problem with NSString stringWithFormat. I want to take the
I came accross a weird problem, I want to do some basic math checks.
I'm paid by the hour and I want to make an app which I
I've building a very basic iphone app where the user will be able to
This is a basic security app and i just want to encrypt & decry-pt
Basic problem I have some large, but logically organised documents - and would like
My basic problem is to generate 2d renders of 3d objects, such as one
I have such a basic problem in Delphi,I can't solve it. My Code: Note:DataR
I have a pretty basic problem but I can't seem to figure it out...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.