Reputation: 111
I am using:
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);
}
}];
}
This gives me a JSON string of ALL data (AND I MEAN ALL) from a Facebook Page. It gives me the posts, IDs of those who liked the posts, every comment, every person who shared. I really just need the post itself, which is listed as 'message' in the JSON result. Is there a way I can do this in the API call, or does it have to be done after?
Also, Is there any way to get it to pull the pictures that are associated with each post? I know how to get photos posted to page, but I just want to view the posts made to the page, and have it also pull up the picture.
Upvotes: 8
Views: 375
Reputation: 4646
this, it's the variable of NSString "link" that you want:
if ([FBSDKAccessToken currentAccessToken]) {
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSDictionary *userData = (NSDictionary *)result;
NSString *facebookID = userData[@"id"];
NSString *link = userData[@"link"];
NSString *locale = userData[@"locale"];
NSString *timezone = userData[@"timezone"];
NSString *last_name = userData[@"last_name"];
NSString *email = userData[@"email"];
NSString *gender = userData[@"gender"];
NSString *first_name = userData[@"first_name"];
} else if (error) {
//tbd
}
}];
} else if (![FBSDKAccessToken currentAccessToken]) {
//tbd
}
Upvotes: 1
Reputation: 6564
You can filter out feed response as below
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);
}
}];
}
As you can check, I've mentioned the parameters which I information I requires to get filter out.
NOTE: You can filter out things according to your requirement.
Please check below link for available filter possibilities on facebook SDK.
https://developers.facebook.com/docs/graph-api/reference/v2.3/user/feed
I hope it will help you, Not sure about the picture you want to pull up but may be 'link.picture' in 'fields' will help you the picture you want to get.
Upvotes: 4
Reputation: 31479
Use
/{page_id}/feed?fields=id,message
With Graph API v2.4 this will be the standard usage that you have to specify each field.
Upvotes: 4