iOS Facebook Open Graph获取发布链接

时间:2015-08-11 03:42:11

标签: ios facebook facebook-graph-api

我正在尝试获取Facebook页面帖子的链接。但是,链接仅显示在操作字段下,并且对于每个喜欢,评论或共享,它再次列出链接。我用:

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"/v2.3/116178611870507/feed?limit=20" parameters:[NSMutableDictionary dictionaryWithObject:@"id, actions, message, full_picture" forKey:@"fields"]]
         startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error)

结果显示在控制台中

{
    data =     (
                {
            actions =             (
                                {
                    link = "https://www.facebook.com/116178611870507/posts/534581860030178";
                    name = Comment;
                },
                                {
                    link = "https://www.facebook.com/116178611870507/posts/534581860030178";
                    name = Like;
                },
                                {
                    link = "https://www.facebook.com/116178611870507/posts/534581860030178";
                    name = Share;
                }
            );

我想我的问题是,我怎样才能访问那里的链接,但是限制只拉一次而不是每次分享或评论?

1 个答案:

答案 0 :(得分:0)

试试这段代码:

NSMutableArray *link = [[NSMutableArray alloc]init];
    NSMutableArray *dataArr = [[NSMutableArray alloc] initWithArray:[yourFacebookResult objectForKey:@"data"]];

    for (int i=0; i < dataArr.count; i++) {
        for (int j=0; j < [[[dataArr objectAtIndex:i] objectForKey:@"actions"] count]; j++) {
            [link addObject:[[[[dataArr objectAtIndex:i] objectForKey:@"actions"] objectAtIndex:j] objectForKey:@"link"]];
        }
    }
    NSLog(@"Your all link -> %@",link);