我正在尝试做世界上最简单的事情:我想要一个节点脚本来获取页面的PUBLIC提要。
我正在尝试这个:
var FB = require('fb' )
FB.api('/flourandfire/feed', 'get', function (res) {
if (!res || res.error) {
console.log(!res ? 'error occurred' : res.error)
return
}
console.log(res.id)
console.log(res.name)
})
它不起作用。
{ message: 'An access token is required to request this resource.',
type: 'OAuthException',
code: 104,
fbtrace_id: 'EiH31CMsyvh' }
所以,我创建了一个拥有该页面的同一用户的“app”并尝试:
var FB = require('fb', { appId: 'XXXXXXXXXXXXXXXXXXXXX', appSecret: 'YYYYYYYYYYYYYYYYYYYYY' })
FB.api('/flourandfire/feed', 'get', function (res) {
if (!res || res.error) {
console.log(!res ? 'error occurred' : res.error)
return
}
console.log(res.id)
console.log(res.name)That is, what's the EASIEST, most permanent way to get the right access token/appId/appSecret/whatever to plumb into these functions and make the call work?That is, what's the EASIEST, most permanent way to get the right access token/appId/appSecret/whatever to plumb into these functions and mThat is, what's the EASIEST, most permanent way to get the right access token/appId/appSecret/whatever to plumb into these functions and make the call work?ake the call work?That is, what's the EASIEST, most permanent way to get the right access token/appId/appSecret/whatever to plumb into these functions and make the call work?
})
依然没有。
{ message: 'An access token is required to request this resource.',
type: 'OAuthException',
code: 104,
fbtrace_id: 'EiH31CMsyvh' }
我尝试为该应用添加访问令牌:
var FB = require('fb', { appId: 'XXXXXXXXXXXXXXXXXXXXX', appSecret: 'YYYYYYYYYYYYYYYYYYYYY' })
FB.api('/flourandfire/feed', 'get', { access_token: 'ZZZZZZZZZZZZZZZZZZZZ' }, function (res) {
if (!res || res.error) {
console.log(!res ? 'error occurred' : res.error)
return
}
console.log(res.id)
console.log(res.name)
})
依然没有:
{ message: 'Invalid OAuth access token.',
type: 'OAuthException',
code: 190,
fbtrace_id: 'Hf8Gjudpwty' }
饲料是公开的。那么,HECK如何得到这个饲料?
也就是说,什么是EASIEST,最永久的方式来获得正确的访问令牌/ appId / appSecret /无论是什么来探究这些功能并使呼叫工作?
我从未使用过fb软件包,但文档告诉我这应该有效:
var FB = require('fb');
FB.options({appId: 'xxx', appSecret: 'xxx'});
FB.setAccessToken('APP-ID|APP-SECRET'); //btw, this is an "App Access Token". Maybe you do not even need this line if you specify the options correctly.
//FB.options({accessToken: 'APP-ID|APP-SECRET'}); //another way according to the docs
FB.api('/flourandfire/feed', (res) => {
if (!res || res.error) {
console.log(!res ? 'error occurred' : res.error);
return;
}
console.log(res);
});
文件:https://www.npmjs.com/package/fb
有关令牌的更多信息: