使用JS SDK和FQL获取Facebook上所有朋友的列表 [英] Get a List of All Friends on Facebook Using JS SDK and FQL

查看:110
本文介绍了使用JS SDK和FQL获取Facebook上所有朋友的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用我的Facebook应用程序获取当前用户的所有朋友的列表:

这是我的代码供您参考:

  var meID =<?php echo $ data ['user_id']; ?取代; 
var queryOnFriends =SELECT uid,name,online_presence,status FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 =+ meID +);
var queryOnFriends1 =SELECT uid,name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 =+ meID +);
var queryOnFriends2 =SELECT uid2 FROM friend WHERE uid1 = me();
var queryUserName =SELECT name,uid FROM user WHERE uid = {0};
var query = FB.Data.query(queryOnFriends2,meID);
query.wait(function(rows){
alert(in callback);
document.getElementById('display')。innerHTML =
'你的名字是'+行[0] .name;
});

参考我尝试使用 var queryUserName 好的,但所有其他人都没有工作,甚至来自FQL示例的简单 queryOnFriends2

应用程序要求正确的权限( read_friendlists,user_online_presence,friends_online_presence )和FB JS SDK似乎初始化好,因为查询用户自己的用户名( queryUserName )的工作但是,在这种失败的情况下,它甚至不执行回调函数!



我做错了什么?

解决方案

OK,我现在得到了...我用php授权我的应用程序,但没有验证!当使用只是facebook jsSDK并启动然后getStatus它自动完成!



然后查询工作!


I am trying to get a list of all friends of the current user using my Facebook application:
Here is my code for your reference:

    var meID = <?php echo $data['user_id']; ?>;
    var queryOnFriends = "SELECT uid, name, online_presence, status FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = " + meID + ")";
    var queryOnFriends1 = "SELECT uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=" + meID + ")";
    var queryOnFriends2 = "SELECT uid2 FROM friend WHERE uid1 = me()";
    var queryUserName = "SELECT name, uid FROM user WHERE uid={0}";
    var query = FB.Data.query(queryOnFriends2, meID);
    query.wait(function(rows){
        alert("in callback");
        document.getElementById('display').innerHTML =
        'Your name is ' + rows[0].name;
    });

Referring to my attempt using var queryUserName works fine, but all the others didn't work, even the simple queryOnFriends2 from the FQL examples.
The application asks for permissions correctly (read_friendlists, user_online_presence, friends_online_presence) and the FB JS SDK seems to initialize well, as querying for the user's own username (queryUserName) works, however, it does not even execute the callback function in the failing cases!

What am I doing wrong?

解决方案

OK i got it now ... i used php to authorize my app ... but didn't authenticate as well! When using just the facebook jsSDK and initalize and then getStatus it does it all automaticly!

Then the queries worked!

这篇关于使用JS SDK和FQL获取Facebook上所有朋友的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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