如何通过code得到页访问令牌? [英] How to get Page Access Token by code?

查看:260
本文介绍了如何通过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.

这是我做的:


  1. 转至图形API资源管理器

  2. 从下拉列表中选择我的应用程序

  3. 点击获得访问令牌

  4. 选择正确的权限( manage_pages / user_events

  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)

要获得网​​页访问令牌我要运行我/帐户在图形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 and publish_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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆