从Node.js服务器自动发布到我的Facebook页面 [英] Automatic post to my facebook page from Node.js server

查看:84
本文介绍了从Node.js服务器自动发布到我的Facebook页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行社交网站的Node.js服务器,也有该网站的Facebook页面.对于用户在我的网站上执行的某些操作,我想在我的应用程序的Facebook页面上发布详细信息.

I have a Node.js server running a social network site and I also have a facebook page for that site. For certain actions performed by users on my site, I want to post details on the facebook page of my app.

我在此处中提到了Thuzi facebook节点sdk,以了解如何将其发布到facebook墙.但是,它需要应用程序ID,应用程序密钥和临时访问令牌.应用程序ID和应用程序密钥是恒定不变的,因此我可以将它们放在配置文件中的某个位置,然后从那里使用.但是,如何在没有前端任何交互的情况下获取访问令牌?所有帖子只会由我们的应用发布,并且也会在我们自己的页面上发布.我只希望由最终用户的操作来触发此操作.有帮助吗?

I referred to Thuzi facebook node sdk here on how to post to facebook wall. However, it requires app id, app secret and a temporary access token. App id and app secret are constant so I can put them somewhere in my config file and use from there. 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 ?

我正在使用Sails.js框架.

I am using Sails.js framework btw.

推荐答案

为此,您将需要使用扩展页面令牌,只需创建一次即可,它将永远有效.然后,您将使用页面令牌发布作为页面".如何获取扩展页令牌:

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. How to get an Extended Page Token:

  • 创建应用
  • 使用图形API资源管理器来生成用户访问令牌(通过使用manage_pagespublish_actions权限)
  • 扩展用户访问令牌(有效期为60天)
  • 通过调用/me/accounts
  • 来请求扩展页面令牌
  • 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)
  • Extend the User Access Token (valid for 60 days)
  • Request an Extended Page Token by calling /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:

  • https://developers.facebook.com/docs/facebook-login/access-tokens/
  • https://developers.facebook.com/docs/graph-api/reference/v2.1/page/feed
  • http://www.devils-heaven.com/facebook-access-tokens/
  • http://www.devils-heaven.com/extended-page-access-tokens-curl/

这篇关于从Node.js服务器自动发布到我的Facebook页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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