2010-02-02 66 views
0

我想检索由用户的朋友发布/发布的状态数据。我写了下面的代码,但只获取用户自己的状态更新。有人能帮忙告诉我我的代码有什么问题吗?谢谢!iphone facebook用户的朋友状态更新

NSString *fql = [NSString stringWithFormat:@"select uid,message from status where uid in (select uid2 from friend where uid1=%lld) order by time desc ", uid]; 

NSDictionary *params = [NSDictionary dictionaryWithObject:fql forKey:@"query"]; 
[[FBRequest requestWithDelegate:self] call:@"facebook.Status.get" params:params]; 

回答

1

您需要将呼叫更改为使用“facebook.fql.query”,因为您正在进行直接查询。

这是我为获得最后的20个朋友的代码更新:

NSString* fql = [NSString stringWithFormat: 
       @"SELECT uid, pic_square, name, status FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = %lld) AND status.time > 0 ORDER BY status.time DESC LIMIT 20", fbSession.uid]; 

NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"]; 
last20FriendsStatusRequest = [FBRequest requestWithDelegate:self]; 
[last20FriendsStatusRequest call:@"facebook.fql.query" params:params]; 

最好的问候,

+0

嗨马特, 谢谢你的提示。 :-) 顺便说一句,你能解释更多关于“直接查询”吗?当我使用fql.query或User.setStatus等时,我总是感到困惑。 谢谢。 – 2010-02-03 00:44:08

+0

“facebook.fql.query”和“facebook.status.get”都是Web服务调用。一个将FQL查询作为参数,而另一个则没有。通过FQL查询,您可以使用更具体的查询语言获得您在状态调用在幕后执行特定查询时的确切结果。 – 2010-02-03 01:06:19

+0

很好的回答!谢谢! – 2010-02-03 01:21:22