Javascript facebook api js(angular)检查两人好友是否返回空数组
我有一个小angularJs应用程序,需要检查两个人在facebook上是否是朋友 正如我遵循facebook官方api指南: 从指南中:Javascript facebook api js(angular)检查两人好友是否返回空数组,javascript,facebook,angularjs,facebook-graph-api,facebook-graph-api-v2.0,Javascript,Facebook,Angularjs,Facebook Graph Api,Facebook Graph Api V2.0,我有一个小angularJs应用程序,需要检查两个人在facebook上是否是朋友 正如我遵循facebook官方api指南: 从指南中: /* make the API call */ FB.api( "/{user-id-a}/friends/{user-id-b}", function (response) { if (response && !response.error) { /* handle the result
/* make the API call */
FB.api(
"/{user-id-a}/friends/{user-id-b}",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
我的代码:
iFriends正在查看阵列中的位置,以便通过FaceBookiFriends进行更新
$scope.isFriends = function(friend_id){
//$scope.myArray[friend_id]
var tmpStr = 'myArray.' + friend_id;
$scope.facebookIsFriends(friend_id);
var unbindWatcher = $scope.$watch(
tmpStr,
function() {
if(!!$scope.myArray[friend_id]){
unbindWatcher();
//call another function with the result.
}
}
);
}
$scope.facebookIsFriends = function(friend_id){
var urlString = '/' + $scope.user.id + "/friends/" + friend_id;
Facebook.api(urlString, function(response) {
$scope.$apply(function() {
$scope.myArray[friend_id] = response;
});
});
}
我得到的回报是:
data: Array[0]
length: 0
__proto__: Array[0]
summary: Object
total_count: 754
__proto__: Object
注:我有754个朋友
重要提示:
1.当我尝试这个时,我得到了相似的结果!我绝对确定我检查了所有的使用数据和扩展权限。
2.我已经正确连接到facebook,我已经做了一些正常工作的查询/me,/me/feed,/{post id}
3.调试代码时,我会得到一个正确的url字符串,如:
/10204551896346735/friends/102050375781129
当我尝试将这些用户都放在graph api explorer中时,我得到了很好的结果非空用户对象
我已经试过无数次了,比如设置一个很长的超时时间,检查它是否随着时间的推移而更新,但什么都没发生。请帮助我,我失去了所有的希望:
谢谢,
Matan您是否尝试过使用硬编码数据调用Facebook API而不使用AngularJS?只是运行Facebook.apirlstring,functionresponse{console.logresponse;};我确实试过了。。在我将api explorer更改为Graph explorer应用程序后,它确实工作了,所以我猜问题出在应用程序本身。。有什么想法吗?