简体   繁体   English

以页面所有者的身份对Facebook页面帖子发表评论,并带有扩展令牌

[英]Comment on Facebook page posts as page owner with extended token

I'm developing a node.js app which manages a Facebook page among other functionalities. 我正在开发一个node.js应用程序,该应用程序可管理其他功能中的Facebook页面。

To comment on user submitted posts, I use the following code in node.js: 要评论用户提交的帖子,我在node.js中使用以下代码:

FB.api(object + '/comments','post',
  { message: COMMENT_I_WANT_TO_SUBMIT, access_token: MY_PAGE_ACCESS_TOKEN },
  function(res){ 
    // deal with res
  }
);

When using my short-lived Facebook page access-token (which I get from Graph API Explorer) the comment submitted is shown as a comment submitted by the page itself (what I want), but when I use my permanent token it is shown as submitted by myself (page owner). 当使用我的短暂Facebook页面访问令牌(从Graph API Explorer获得)时,提交的评论显示为页面本身(我想要的)提交的评论,但是当我使用永久令牌时,显示为由我自己(页面所有者)提交。

To get this permanent token I followed these instructions: https://stackoverflow.com/a/28418469/4713311 为了获得此永久令牌,我遵循以下说明: https : //stackoverflow.com/a/28418469/4713311

The token has my name associated to it since I had to grant permissions to manage the pages I own to generate the token. 令牌具有与之关联的名称,因为我必须授予权限来管理自己拥有的页面以生成令牌。 I believe this token has the proper permissions since the token debugger shows the following permissions in scope: "manage_pages, publish_pages, publish_actions, public_profile" 我相信此令牌具有适当的权限,因为令牌调试器在范围内显示以下权限:“ manage_pages,publish_pages,publish_actions,public_profile”

Is there any way I can use this never expiring token to comment on posts with the page name instead of my own? 我有什么办法可以使用这个永不过期的令牌对页面名称而不是我自己的帖子发表评论?

A Page Access Token should have not only "User ID" but also "Profile ID" associated, which wasn't the case for the extended page access token. 页面访问令牌不仅应具有“用户ID”,而且还应具有“个人资料ID”,而扩展页面访问令牌不是这种情况。

A Page Access Token isn't "extendable", to get a permanent page access token I had to request one with a permanent User Access Token, as explained here 一个页面访问令牌不“扩展”,以获得永久页面访问令牌我不得不要求一个具有永久用户访问令牌,如解释在这里

Using as short-lived access token I got from Graph API Explorer (Select App -> Get Token -> Select permissions manage_pages , publish_pages , publish_actions and other you may need -> Grab the token that fills the "Access Token" text box) I made the following call to extend the token. 使用从Graph API Explorer获得的短期访问令牌(选择应用程序->获取令牌->选择权限manage_pagespublish_pagespublish_actions以及其他您可能需要的权限->获取填充“访问令牌”文本框的令牌)进行了以下调用以扩展令牌。 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}

Using the token returned, you can simply call /me/accounts and copy the page's access_token This token is a permanent Page Access Token, to confirm you can use the token debugger and verify it has your "User ID" and your page's "Profile ID" 使用返回的令牌,您可以简单地调用/me/accounts并复制页面的access_token此令牌是永久的页面访问令牌,以确认您可以使用令牌调试器并验证其是否具有“用户ID”和页面的“个人资料ID” ”

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

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