Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting Through Graph API of Facebook Page on iOS

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.

like image 914
user717452 Avatar asked Jul 17 '15 03:07

user717452


People also ask

How do I get Facebook Page Insights on graph API?

You can access Page Insights by typing /insights after the name of your page in the URL field. This command will retrieve all of the Insights associated with your Page. Type "/insights" after your company name. Click the Submit button.

What data can you get from Facebook Graph API?

With the Facebook Graph API, you can access a wide range of user data, including user information such as name, email address, birthday, and friends list in JSON. You can also access information about pages that a user has liked or engaged with on Facebook, as well as events and photos that they have posted or shared.

Does Facebook use graph API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

How do I make a graph API on Facebook?

Go to “My apps” drop down in the top right corner and select “add a new app”. Choose a display name and a category and then “Create App ID”. Again get back to the same link developers.facebook.com/tools/explorer. You will see “Graph API Explorer” below “My Apps” in the top right corner.


2 Answers

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.

like image 130
Kiran Jasvanee Avatar answered Dec 08 '22 22:12

Kiran Jasvanee


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.

like image 36
Tobi Avatar answered Dec 08 '22 23:12

Tobi