fql获取好友列表错误

时间:2012-01-29 21:42:57

标签: javascript facebook facebook-graph-api facebook-fql

这是我的问题:

 fql?q=SELECT uid, name, pic_square, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

这是错误:

(#604) Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http://developers.facebook.com/docs/reference

这是js代码:

var query = encodeURI("SELECT uid, name, pic_square, sex FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())");
    FB.api('fql?q=' + query, function(response) {
        console.dir(response);
        if(! jQuery.isEmptyObject(response)&& ! jQuery.isEmptyObject(response.data)) {
            var maleList = $('#male-list');
            var femaleList = $('#female-list');
            for (var friend in response.data) {
                var item = STValentines.buildFriendItem(friend);
                if (friend.sex === 'male')
                    maleList.append(item);
                else
                    femaleList.append(item);
            }
        }
    });

这是常见问题吗?我可以做些什么吗? 有没有走动?谢谢你的帮助

1 个答案:

答案 0 :(得分:1)

这可能是逃避角色的问题 您应该尝试在FQL查询上使用escape()方法,然后再将其交给JavaScript SDK:

var escapedFQLQuery = escape('SELECT uid, name, pic_square, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())');
//escapedFQLQuery now is : "SELECT%20uid%2C%20name%2C%20pic_square%2C%20sex%20FROM%20user%20WHERE%20uid%20IN%20%28SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20%3D%20me%28%29%29"
FB.api(
  {
    method : 'fql.query',
    query  : escapedFQLQuery
  });