iOS Facebook Connect新闻源

时间:2011-08-03 08:24:58

标签: objective-c facebook-graph-api

我需要获取用户新闻Feed数据。

目前我正在使用这个:
[[FBManager defaultManager]getFBRequestWithGraphPath:@"me/home" params: andDelegate:self];

然后:

- (void)request:(FBRequest *)request didLoad:(id)result {   
if ([result isKindOfClass:[NSArray class]]) 
    result = [result objectAtIndex:0];}

结果给了我一堆数据。但是如何单独提取这些?也许名称和消息例如??

1 个答案:

答案 0 :(得分:0)

我将使用requestWithGraphPath更改为requestWithMethodName。

以下是示例代码:

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   [NSString stringWithFormat:@"SELECT post_id, actor_id, message FROM stream WHERE filter_key = 'others '", @"query",
                                   nil];  

[facebook requestWithMethodName: @"fql.query" andParams: params andHttpMethod: @"POST" andDelegate: self];

然后在请求中使用didLoad方法:

- (void)request:(FBRequest *)request didLoad:(id)result 
{

    if ([result isKindOfClass:[NSArray class]]) 
          result = [result objectAtIndex:0];

     friendID = [[result objectForKey:@"actor_id"]copy];
     friendMsg = [[result objectForKey:@"message"]copy];
}

iOS FB Connect SDK上的Facebook文档非常融合。如果你知道一点SQL(fql),它会有所帮助:)