11

I need to generate a Page Access Token for a webpage that I have, this token will be used by the webpage to post to its Facebook Page feed.

This is what I do :

  1. Go to Graph API Explorer
  2. Choose my app from the dropdown
  3. Click Get Access Token
  4. Choose correct permissions(manage_pages/user_events)

To get the Page Access Token I have to run me/accounts in the Graph API Explorer. This will show all the pages I got with a new Page Access Token (short lived(about 60 min)) to each one.

This Page Access Token will work just fine to use in my C# code to post to the feed.

Problem

When another user uses my webpage to post a post I need to generate a new Page Access Token(in code) and then use it to post the userpost to the site´s facebook feed. The problem is that I could clearly not be there to grant the post so how do I handle this?

I could obviously not run the me/accounts(in code) command to get the Page Access Token from here.

I have looked at extended Access Token but this will last 60 days and then it will be the same problem as above.

3
  • why can you not use /me/accounts? Commented Aug 24, 2014 at 10:03
  • I suspect that when running /me/accounts/ it will go to facebook and fetch the data based on "me". So if another user is posting to the website on another computer it will ask for that persons accounts instead of my(admin) accounts and it will not find any access token there. Besides, it will demand the other user to logon to facebook and that is not what I want. I only want my webpage to post to the webpage´s facebook feed without involving the user that are triggering the action(post a post in my forum) on my webpage. Commented Aug 24, 2014 at 10:18
  • alright, now i understand. so you want to store the page token and use it for every other user? Commented Aug 24, 2014 at 10:24

2 Answers 2

15

What you need is an Extended Page Token:

Extended Page Tokens are valid forever, so you don´t need to generate a new one all the time.

Source (including information about all the Tokens): http://www.devils-heaven.com/facebook-access-tokens/

Sign up to request clarification or add additional context in comments.

6 Comments

How do I run the extended user token with the /me/accounts command?
/me/accounts?access_token=xxxx
I saw somthing about a new version of Facebook API? Will this still work in the new version?
yes, that part did not change: developers.facebook.com/docs/apps/changelog
Excellent! It took me 3 days to find anyone who answered this. Thank you.
|
5

On https://developers.facebook.com/docs/pages/access-tokens

Getting Page Access Tokens

GET /{page-id}?fields=access_token&access_token={user_access_token}

The response will look like this:

{
  "access_token": "{your-page-access-token}",
  "id": "{page-id}"
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.