[英]Facebook access token not accepted to Open Graph using Node.js facebook-node-sdk
Posting an Open Graph action using the Node.js facebook-node-sdk
module gives me {"error": "An active access token must be used to query information about the current user."}
. 使用Node.js
facebook-node-sdk
模块发布Open Graph操作会给我{"error": "An active access token must be used to query information about the current user."}
。
var FB = require( 'fb' )
var path = '/me?' + namespace + ':' + action_type_name
var body = {
access_token: myAccessToken,
myAction : myCustomObjectURL
}
FB.api( path, 'post', body, function( res )
{
if( res.error ) {
console.log( 'the call to open graph failed: ' + res.error.message );
}
else {
console.log( 'success' )
}
})
If I print this access token and use it with cURL ( curl https://graph.facebook.com/me?access_token=myAccessToken
), it returns correctly, no error. 如果我打印此访问令牌并将其与cURL(
curl https://graph.facebook.com/me?access_token=myAccessToken
)一起使用,则会正确返回,没有错误。 Facebook also shows that the app has permission to post as this user. Facebook还显示该应用有权以此用户身份发布。 So what am I doing wrong here?
那么我在这里做错了什么?
D'oh, stupid question. 噢,愚蠢的问题。 It turns out I needed a slash instead of a question mark in the URL path:
path = '/me/' + ...
事实证明我需要在URL路径中使用斜杠而不是问号:
path = '/me/' + ...
Actually this is a bug of the node facebook api. 实际上这是节点facebook api的错误。 When you use a '?'
当你使用'?'时 in your api-calls the accesstoken gets appended with another '?'
在你的api-calls中,accesstoken附加了另一个'?' https://github.com/Thuzi/facebook-node-sdk/blob/master/fb.js#L268
https://github.com/Thuzi/facebook-node-sdk/blob/master/fb.js#L268
This leads to a api-call like this one: https://graph.facebook.com/me/friends?limit=10?access_token=vSAEFfionhaWFwai ... 这导致像这样的api-call: https : //graph.facebook.com/me/friends ? limit = 10 ? access_token = vSAEFfionhaWFwai ...
You see multible '?' 你看多了'?' in the request and Facebook can not find the accesstoken anymore because of this.
在请求中,Facebook因此无法找到accessstoken。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.