如何通过code得到页访问令牌? [英] How to get Page Access Token by code?
问题描述
我需要生成一个页面访问令牌,我,此令牌将被网页所张贴到其Facebook页面饲料的网页。
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.
这是我做的:
- 转至图形API资源管理器
- 从下拉列表中选择我的应用程序
- 点击
获得访问令牌
- 选择正确的权限(
manage_pages
/user_events
)
- Go to Graph API Explorer
- Choose my app from the dropdown
- Click
Get Access Token
- Choose correct permissions(
manage_pages
/user_events
)
要获得网页访问令牌
我要运行我/帐户
在图形API浏览器。这将显示我一个新的页面访问令牌(短暂(约60分钟))得到了所有页面每一个。
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.
本页面访问令牌
将工作只是罚款在我的C#code使用张贴到饲料中。
This Page Access Token
will work just fine to use in my C# code to post to the feed.
问题
当另一个用户使用我的网页上张贴文章,我需要生成一个新的网页访问令牌
(在code),然后用它来发布userpost到site's Facebook的饲料。问题是,我可以清楚地没能亲自授予的帖子让我怎么处理呢?
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?
我显然不能运行我/帐户
(在code)命令来获得网页访问令牌
从这里开始。
I could obviously not run the me/accounts
(in code) command to get the Page Access Token
from here.
我已经看过延长访问令牌,但这将持续60天,那么这将是同样的问题如上。
I have looked at extended Access Token but this will last 60 days and then it will be the same problem as above.
推荐答案
您需要的是一个扩展页令牌:
What you need is an Extended Page Token:
- 生成用户访问令牌与
manage_pages
和publish_actions
- 生成扩展用户令牌(有效期60天):<一href=\"https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=[app-id]&client_secret=[app-secret]&fb_exchange_token=[short-lived-token]\">https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=[app-id]&client_secret=[app-secret]&fb_exchange_token=[short-lived-token]
- 通话
/ ME /帐户
通过扩展用户令牌得到扩展页令牌
- generate User Access Token with
manage_pages
andpublish_actions
- generate Extended User Token (valid for 60 days): https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=[app-id]&client_secret=[app-secret]&fb_exchange_token=[short-lived-token]
- call
/me/accounts
with the Extended User Token to get Extended Page Tokens
扩展页令牌是永远有效,所以你鸵鸟政策需要生成一个新的所有的时间。
Extended Page Tokens are valid forever, so you don´t need to generate a new one all the time.
来源(包括所有的标记信息):<一href=\"http://www.devils-heaven.com/facebook-access-tokens/\">http://www.devils-heaven.com/facebook-access-tokens/
Source (including information about all the Tokens): http://www.devils-heaven.com/facebook-access-tokens/
这篇关于如何通过code得到页访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!