简体   繁体   English

如何使用Facebook应用程序获取Facebook用户令牌

[英]How to get the facebook user token with a facebook application

I have a facebook application with has to post updates on specific facebook page. 我有一个Facebook应用程序,必须在特定的Facebook页面上发布更新。 The application has rights to post updates on the facebook wall of the page's admin. 该应用程序有权在页面管理员的Facebook墙上发布更新。 But how can i get the (admin's) users access token, which i need to get the access token of the page. 但是我如何获取(管理员)用户的访问令牌,我需要获取该页面的访问令牌。 Do i have to save the access tokenthe first time the user allows the app to post (offline access)? 用户第一次允许该应用发布(离线访问)时,是否需要保存访问令牌?

Thanks for your reply! 感谢您的回复!

I use the Facebook C# SDK as well. 我也使用Facebook C#SDK。 You'll need the following permissions: 您将需要以下权限:

manage_pages  
read_stream  
publish_stream

HTTP Get to "me/accounts" and get the .data object off of the returned value. HTTP转到“我/帐户”,并从返回值中获取.data对象。 This will be a list of the following: 这将是以下列表:

  var list = ApiGet("me/accounts").data;
  foreach (dynamic acc in list)
  {              
    var name = (string)acc.name;
    var accessToken = (string)acc.access_token;
    var category = (string)acc.category;
    var pageId = (string)acc.id;
  }

As you can see, each one of the pages have their own unique access token. 如您所见,每个页面都有自己的唯一访问令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM