Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

c# - How to get Page Access Token by code?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...