我正在用Ionic框架做一个混合应用程序。我想实现一个facebook事件系统来参加一些活动。我有这个:
ngFB.api(
'/666945880120392/attending',
'GET',
{},
function(response) {
// Insert your code here
}
);我的app.js文件中有这样的app.js:
ngFB.init({appId: '[APP_ID]'});我的错误是:
openfb.js:256 GET https://graph.facebook.comundefined/?access_token=undefined net::ERR_NAME_NOT_RESOLVED我在找解决办法,但没有回答。我还在开发人员facebook控制台上尝试,答案是正确的:
发生什么事了?谢谢!
编辑1
多亏了@e 666,我现在做到了
ngFB.api({
method: 'GET',
path: '/666945880120392/attending'
}).then(function(response) {
console.log(response);
}).catch(function(error) {
console.error(error);
});现在的错误是,如果我一直使用一个帐户进行日志记录,则事件的返回是:
Object {data: Array[1], paging: Object}内部数据是另一个人的名字,是处理事件的唯一人,而不是使用访问令牌记录的人。谢谢!
编辑2
我提出了另一个问题,因为这不是我所希望的结果,我需要去参加一个活动,没有得到参加活动的人的名单。我现在有了这个:
ngFB.api(
"/666945880120392/attending",
function (response) {
if (response && !response.error) {
console.dir(response);
}
}
);access_token没有问题,响应是
openfb.js:256 GET https://graph.facebook.comundefined/?access_token=EAABlK6y7pOUBAN3CPWdZB5FL…LCpXL9Bd3ELHQZAA6EJc6cCheAxUUnL59ZCZAf7aROCapJxiu991fxjDkxmMO651rfuREwZDZD net::ERR_NAME_NOT_RESOLVED在facebook https://developers.facebook.com/tools/explorer/?method=POST&path=666945880120392%2Fattending&version=v2.5的页面上
反应是
{
"error": {
"message": "(#299) Requires extended permission: rsvp_event",
"type": "OAuthException",
"code": 299,
"fbtrace_id": "G7HFJ48pbkx"
}
}但我有这个许可。有人能帮帮我吗?
发布于 2016-08-17 21:03:51
首先,路径是未定义的,因为您没有正确使用api方法。这就是你需要如何使用它:
ngFB.api({
method: 'GET',
path: '/666945880120392/attending'
}).then(function(response) {
console.log(response);
}).catch(function(error) {
console.error(error);
});此外,您在access_token中没有定义。正如我在库代码中所看到的那样,我不确定您是否可以不以用户身份登录就使用这个库来拥有一个access_token。
要拥有一个access_token,您需要使用以下函数:
ngFB.login({scope: 'email'}).then(function(response) {
console.log('Access token' + response.authResponse.accessToken);
}).catch(function(error) {
console.error(error);
});然后,access_token将自动附加到您使用OpenFB发出的请求。
您可以在这里找到关于如何使用这个库的更完整的示例:https://github.com/ccoenraets/OpenFB/blob/master/indexng.html
https://stackoverflow.com/questions/38999366
复制相似问题