如何通过代码获取页面访问令牌? [英] How to get Page Access Token by code?

查看:984
本文介绍了如何通过代码获取页面访问令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为网页生成一个页面访问令牌,该网页将被使用该页面发布到其Facebook页面Feed。



是我做的:


  1. 转到图表API资源管理器

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

  3. 点击获取访问令牌

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

要获取页面访问令牌我必须运行我/ accounts 在Graph API资源管理器中。这将显示所有的页面,我有一个新的页面访问令牌(短命(约60分钟))到每一个。



这个页面



问题 p>

当另一个用户使用我的网页发布帖子时,我需要生成一个新的页面访问令牌(在代码中)和然后使用它将用户页面发布到该网站的Facebook订阅源。问题是,我可以明确地不在那里给出这个帖子,我该如何处理?



我显然不能运行帐户(代码)命令从这里获取页面访问令牌



我查看了扩展访问令牌,但是这将持续60天,那么这将是与上述相同的问题。

解决方案

您需要的是扩展页面令牌:





扩展页面令牌永久有效,因此您不需要生成一个新的时间。



来源(包括有关所有令牌的信息): http://www.devils-heaven.com/facebook-access-tokens/


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.

解决方案

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/

这篇关于如何通过代码获取页面访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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