Reputation: 55
Digging around for several days to get my PHP app write on facebook fan page and got almost crazy.
Already given my app manage_page permission for a particular facebook page.
Visited
h..s//www.facebook.com/dialog/oauth?client_id=APP_ID&redirect_uri=SOME_FALLBACK_URL_TO_GET_ACCESS_TOKEN_FROM_URL&response_type=token&scope=manage_pages,publish_stream
Copied access token from result of previous step
Visited
h..s//graph.facebook.com/me/accounts?access_token=COPIED_ACCESS_TOKEN
Got the result as following:
"data": [
{
"name": "PAGE_TITLE",
"access_token": "SHORT_LIVING_ACCESS_TOKEN",
"category": "Local/travel",
"id": "PAGE_ID_THAT_APP_IS_TO_WRITE_ON_WALL",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
},
Copied the SHORT_LIVING_ACCESS_TOKEN
Visited
h..s://graph.facebook.com/oauth/access_token?client_id={APP_ID}&client_secret={APP_SECRET}&grant_type=fb_exchange_token&fb_exchange_token={SHORT_LIVING_ACCESS_TOKEN_FROM_STEP_5}
Getting the error and stuck here:
{"error_code":1,"error_msg":"An unknown error occurred"}
p.s. I correctly replaced {APP_ID}
, {APP_SECRET}
where necessary.
Please, help!
Upvotes: 1
Views: 525
Reputation: 96271
You’re doing it the wrong way around, I think. You are getting a short-lived page access token and try to prolong that.
What you should do, is get a short-lived user access token, prolong that, and then go get the page access token with the long-lived user access token.
That process should give you a page access token with no default expiry.
Upvotes: 2