订购facebook好友列表回复

时间:2012-06-13 00:27:19

标签: javascript facebook facebook-javascript-sdk

我正在列出facebook的朋友:

FB.api('/me/friends?fields=id,name,updated_time&date_format=U&<?=$access_token?>',
                    {limit:3,
                    function(response){      console.log('Friend name: '+response.data[0].name);
                    }
    );

但我希望能够自定义(随机首选)订单,我该怎么做?

请注意:i don't want to randomize the response,我希望获得随机回复。

由于

1 个答案:

答案 0 :(得分:2)

您所链接的SO帖子的可接受解决方案的哪一部分是不可接受的?使用FB.Data.query可以指定您想要的任何订单(包括ORDER BY rand())。

EDIT

实际上不知道这是否有效,但你基本上想要这个:

FB.api('/fql?q={"all+friends":"SELECT+id,+name,+profile_update_time+FROM+user+WHERE+id+IN+(SELECT+uid2+FROM+friend+WHERE+uid1+=+me())"}&date_format=U&<?=$access_token?>',
  ...
);

重要的部分是FQL查询:

SELECT id, name, profile_update_time FROM user WHERE id IN (SELECT uid2 FROM friend WHERE uid1 = me())