FQL查询以获取用户的Facebook好友的性别PLUS meeting_sex

时间:2011-12-22 16:41:20

标签: iphone objective-c facebook-graph-api facebook-fql fbrequest-form

听起来不那么活泼 - 我正在使用以下代码来获取用户的男性或女性朋友,并且它工作正常。但是,我还想查看他们的'meeting_sex',它是用户的朋友有兴趣会见的性别列表,即男性,女性或两者。 (描述here

meeting_sex需要我已添加到图形API资源管理器的friends_relationship_details权限,但我的输出如下所示:

"data": [
{
  "name": "ABCDEF", 
  "pic_square": "https://abcdefg.jpg", 
  "sex": "male", 
  "meeting_sex": null, 
  "uid": 123456789
}, 

即。 meeting_sex将返回null。我知道meeting_sex是一个数组,不仅仅是一个字符串,还有其他元素,但为什么它会返回null?

我是FQL的新手,实际上是任何QL,所以一旦我确实让数组正确读取,我该如何进行比较呢?即所以我只回报那些喜欢女性的男性或喜欢MEN等男性的男士。这是我现在的代码:

NSString *queryString =  [NSString stringWithFormat:@"SELECT name, pic_square, sex, meeting_sex, uid FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND sex = 'male' ORDER BY name"];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys: queryString, @"query", nil];

[FBRequest getRequestWithParams:dictionary
                     httpMethod:@"GET" 
                       delegate:self
                     requestURL:@"fql.query"];

感谢您的帮助:)

迈克尔

3 个答案:

答案 0 :(得分:1)

我在我的帐户上尝试了这个,除了我的一个朋友之外我都得到了空值。对于meeting_for和meeting_sex

,它们都有一个空数组

我发现有些人建议不再使用它了:

http://forum.developers.facebook.net/viewtopic.php?id=103173

此外,似乎存在很多隐私问题:

请参阅https://www.facebook.com/settings/?tab=privacy点击“应用和网站”,然后“人们如何将您的信息带到他们使用的应用中”

同样来自https://developers.facebook.com/docs/reference/rest/users.getInfo/

User Privacy and Visible Data

Important: Depending upon the user's privacy settings (including whether the user has decided to opt out of Platform completely), you may not see certain user data. For any user submitted to this method, the following user fields are visible to an application only if that user has authorized that application and specifically chose to reveal them:

    meeting_for
    meeting_sex
    religion

修改

Graph API的用户(https://developers.facebook.com/docs/reference/api/user/)对象中的新功能:

  

<强> interested_in       用户感兴趣的性别。user_relationship_detailsfriends_relationship_detailsarray包含字符串。

答案 1 :(得分:0)

该文档说明需要user_relashionship_details friends_relationship_details。我认为您需要添加user_relashionship_details以获取有关用户本身的详细信息,而不仅仅是他们的朋友。

答案 2 :(得分:0)

对我来说,我能够从json属性获取我想要的“meeting_sex”数据: “性别”:“男性”, “interested_in”:[“女性”]

希望这有帮助。