简体   繁体   English

从Node.js服务器自动发布到我的Facebook页面

[英]Automatic post to my facebook page from Node.js server

I have a Node.js server running a social network site and I also have a facebook page for that site. 我有一个运行社交网站的Node.js服务器,我也有一个该网站的Facebook页面。 For certain actions performed by users on my site, I want to post details on the facebook page of my app. 对于我网站上的用户执行的某些操作,我想在我的应用的Facebook页面上发布详细信息。

I referred to Thuzi facebook node sdk here on how to post to facebook wall. 在这里提到了Thuzi facebook node sdk如何发布到facebook墙。 However, it requires app id, app secret and a temporary access token. 但是,它需要app id,app secret和临时访问令牌。 App id and app secret are constant so I can put them somewhere in my config file and use from there. 应用程序ID和应用程序密码是不变的,所以我可以将它们放在我的配置文件中并从那里使用。 But how do I get the access token without any interaction from front-end ? 但是如何在没有前端交互的情况下获取访问令牌? All posts will be published by our app only and that too on our own page. 所有帖子将仅由我们的应用程序发布,也将在我们自己的页面上发布。 I just want this to be triggered by the end user's actions. 我只想让最终用户的动作触发它。 Any help ? 有帮助吗?

I am using Sails.js framework btw. 我正在使用Sails.js框架顺便说一句。

You would need to use an Extended Page Token for that, you only need to create it once and it will stay valid forever. 您需要使用扩展页面令牌,您只需创建一次它就会永久有效。 And you will post "as Page" with a Page Token. 并且您将使用页面标记发布“as Page”。 How to get an Extended Page Token: 如何获得扩展页面令牌:

  • Create an App 创建一个应用程序
  • Use the Graph API Explorer to generate a User Access Token (by authorizing the App with the manage_pages and publish_actions permission) 使用Graph API Explorer生成用户访问令牌(通过使用manage_pagespublish_actions权限授权应用程序)
  • Extend the User Access Token (valid for 60 days) 扩展用户访问令牌(有效期为60天)
  • Request an Extended Page Token by calling /me/accounts 通过调用/me/accounts请求扩展页面令牌

Store that Extended Page Token on your server and use it for posting on the Page wall . 将扩展页面令牌存储在您的服务器上,并使用它在页面墙上发布

Here are some additional resources, explaining everything in detail: 以下是一些额外的资源,详细解释了所有内容:

I am also digging more in to this nowdays As I am working on a node module for this. 我现在也在挖掘更多内容因为我正在为此节点模块工作。

Till now I got to know that we can create a temporary access_token and we can than extend that token upto max 60 days. 直到现在我才知道我们可以创建一个临时的access_token,我们可以将该令牌延长至最多60天。

For this after getting temporary token you need to make a call to this url to get a access token with 60 days validity. 在获得临时令牌后,您需要调用此URL以获取具有60天有效期的访问令牌。

https://graph.facebook.com/oauth/access_token?client_id= &client_secret=&grant_type=fb_exchange_token&fb_exchange_token= https://graph.facebook.com/oauth/access_token?client_id=&client_secret =&grant_type = fb_exchange_token&fb_exchange_token =

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

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