在iOS上通过Facebook页面的图谱API排序

use*_*452 8 json facebook facebook-graph-api ios

我在用:

if ([FBSDKAccessToken currentAccessToken]) {
        [[[FBSDKGraphRequest alloc] initWithGraphPath:@"/v2.3/ID/feed" parameters:nil]
         startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
             if (!error) {
                 NSLog(@"fetched user:%@", result);
             }
         }];
    }   
Run Code Online (Sandbox Code Playgroud)

这给了我一个来自Facebook页面的所有数据的JSON字符串(AND I MEAN ALL).它给了我帖子,喜欢帖子的人的ID,每个评论,每个分享的人.我真的只需要帖子本身,它在JSON结果中列为'message'.有没有办法在API调用中执行此操作,还是必须在之后执行?

此外,有没有办法让它拉出与每个帖子相关的图片?我知道如何将照片发布到页面,但我只是想查看对页面发布的帖子,并让它拉出图片.

Kir*_*nee 4

您可以过滤掉 feed 响应,如下所示

if ([FBSDKAccessToken currentAccessToken]) {
    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"/v2.3/ID/feed" parameters:[NSMutableDictionary dictionaryWithObject:@"id, message, link.picture" forKey:@"fields"]]
     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
         if (!error) {
             NSLog(@"fetched user:%@", result);
         }
     }];
}   
Run Code Online (Sandbox Code Playgroud)

正如您可以检查的那样,我已经提到了我需要过滤掉的参数。
注意:您可以根据您的要求过滤掉一些内容。
请检查下面的链接,了解 facebook SDK 上可用的过滤器可能性。
https://developers.facebook.com/docs/graph-api/reference/v2.3/user/feed
我希望它能帮助你,不确定你想要拉起的图片,但可能是“link.picture”在“字段”中将帮助您获得想要的图片。