无法在iPhone应用程序中获取Facebook好友列表

时间:2010-11-11 11:59:14

标签: facebook ios4

我正在使用fbconnect获取所有者的Facebook好友列表。为此,我正在实施:

FBSession* _session;
FBLoginButton *loginButton;

并在.m文件中:

- (void)session:(FBSession*)session didLogin:(FBUID)uid {
NSLog(@"User with id %lld logged in.", uid);
[self getFriendsName];

}


-(void)getFriendsName
{
    NSString* fql = [NSString stringWithFormat:@"SELECT flid, name FROM friendlist WHERE owner ==%lld",_session.uid];
    NSLog(@"the query is %@",fql);
    NSDictionary* params =[NSDictionary dictionaryWithObject:fql    forKey:@"query"];
    [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
}



- (void)sessionDidNotLogin:(FBSession*)session {
}



- (void)sessionDidLogout:(FBSession*)session {
}



- (void)request:(FBRequest*)request didLoad:(id)result {
    if ([request.method isEqualToString:@"facebook.fql.query"]) {

        NSArray* users = result;

        NSLog(@"the response is %@",[users description]);


    }
}

但问题是结果是零。 我也试过这些fql

SELECT flid, name FROM friendlist WHERE owner =%lld",_session.uid

SELECT flid, name FROM friendlist WHERE uid ==%lld",_session.uid

但徒劳无功。

但是如果我用

替换查询
select name,pic from user where uid == %lld", session.uid

它有效。

我没理由。

1 个答案:

答案 0 :(得分:0)

试试这个:

NSString* fql = [NSString stringWithFormat:@"SELECT uid, name from user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=%lld)", self.usersession.uid];