Facebook 图 API RSS 订阅

Facebook Graph API RSS Feed

我曾经使用 Facebook 的 PHP 在我的应用程序中返回 RSS 源。现在已弃用。在 Facebook 开发者页面上显示

"Page RSS Feed endpoint - at https://www.facebook.com/feeds/page.php is now deprecated and will stop returning data from June 23, 2015. Developers should call the Graph API's /v2.3/{page_id}/feed endpoint instead. This returns JSON rather than RSS/XML."

我没有使用 Facebook Graph API。是否有关于如何像他们在这里提到的那样使用图表 API 的好教程?

我设置了一个名为 FriendArray 的 class,它只有一些字符串属性供我存储 link、图片 url、[=18= 的第一段的字符串],以及整个 post。然后,在我的 TableViewController 中,我使用:

-(void)someMethod {
    NSLog(@"App Opened");
        if ([FBSDKAccessToken currentAccessToken]) {
        [self.loginButton removeFromSuperview];
        NSLog(@"Logged In");
        [[[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) {
             if (!error) {
               //  NSLog(@"fetched user:%@", result);
                 self.friendObjects = [result objectForKey:@"data"];
                 self.jobsTemp = [[NSMutableArray alloc] initWithCapacity:self.friendObjects.count];
                 //  NSLog(@"%@", self.friendObjects);
                 for(NSDictionary *jobsInfo in self.friendObjects) {
                     NSArray *paragraphs = [[jobsInfo valueForKey:@"message" ] componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];

                     NSMutableArray *testing = jobsInfo[@"actions"];
                     NSMutableArray *testing2 = [testing valueForKey:@"link"];
                     FriendArray *jobby = [[FriendArray alloc] init];
                     jobby.message = [paragraphs objectAtIndex:0];
                     // jobby.name = jobsInfo[@"additional"];
                     jobby.picture = jobsInfo[@"full_picture"];
                     jobby.dateCreated = jobsInfo[@"created_time"];
                     jobby.allOfIt = jobsInfo[@"message"];
                     jobby.theLink = [testing2 objectAtIndex:0];

                     NSLog(@"%@", [testing2 objectAtIndex:0]);

                     if (jobby.allOfIt == nil) {


                         jobby.theHtml = [[[[NSString stringWithFormat:@"<html><body><img src=\"%@\">", jobby.picture ] stringByAppendingString:@"\n"] stringByAppendingString:@""] stringByAppendingString:@"</body></html>"];
                         NSLog(@"Name%@", jobby.theHtml);

                         [self.jobsTemp addObject:jobby];
                     }
                     else {
                         jobby.theHtml = [[[NSString stringWithFormat:@"<html>"
                                            "<head>"
                                            "<script type=\"text/javascript\" >"
                                            "function display(img){"
                                            "var imgOrigH = document.getElementById('image').offsetHeight;"
                                            "var imgOrigW = document.getElementById('image').offsetWidth;"
                                            "var bodyH = window.innerHeight;"
                                            "var bodyW = window.innerWidth;"
                                            "if((imgOrigW/imgOrigH) > (bodyW/bodyH))"
                                            "{"
                                            "document.getElementById('image').style.width = bodyW + 'px';"
                                            "document.getElementById('image').style.top = (bodyH - document.getElementById('image').offsetHeight)/2  + 'px';"
                                            "}"
                                            "else"
                                            "{"
                                            "document.getElementById('image').style.height = bodyH + 'px';"
                                            "document.getElementById('image').style.marginLeft = (bodyW - document.getElementById('image').offsetWidth)/2  + 'px';"
                                            "}"
                                            "}"
                                            "</script>"
                                            "</head>"
                                            "<body style=\"margin:0;width:100%%;height:100%%;\" >"
                                            "<img id=\"image\" src=\"%@\" onload=\"display()\"  /><font size=5><div align=\"center\">", jobby.picture ] stringByAppendingString:jobby.allOfIt] stringByAppendingString:@"</font></div></body></html>"];
                         NSLog(@"Name%@", jobby.theHtml);

                         [self.jobsTemp addObject:jobby];
                     }

                 }
                 self.jobsArray = self.jobsTemp;
                 //NSLog(@"ARRAY%@", self.jobsArray);//set @property (nonatomic, copy) NSArray *jobsArray; in the .h
                 [self.tableView reloadData];

                 //   NSLog(@"%@", self.theEntries);

             }
             else {
                 NSLog(@"%@", error);
                 UIAlertView *error2 = [[UIAlertView alloc] initWithTitle:@"ERROR" message:[NSString stringWithFormat:@"%@", error ] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
                 [error2 show];
             }
         }];
    }      else {
        NSLog(@"Not Logged In");
        UIAlertView *login = [[UIAlertView alloc] initWithTitle:@"Please Login" message:@"Stronger Marriages now requires a login to Facebook in order to access its latest posts and messages.  Thank you!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
        [login show];
    }
    //[self refresh];
}

这给了我 Link、整个 post、post 的第一段,以及 URL 到更大尺寸的图像(如果存在的话)。从那里开始,只需使用返回的数据设置 cellForRowAtIndexPath 方法即可。