Question

I have used FacebookSDK.framework for Facebook integration in my application. I have to like one facebook page from application. I have used following code for liking page.

   NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"https://www.facebook.com/demoappname"
                            , @"object",
                            nil
                            ];
    /* make the API call */
    [FBRequestConnection startWithGraphPath:@"me/og.likes"
                                 parameters:params
                                 HTTPMethod:@"POST"
                          completionHandler:^(
                                              FBRequestConnection *connection,
                                              id result,
                                              NSError *error
                                              )
    {

        NSDictionary *currentResult= [(NSArray *)[result data] objectAtIndex:0];

        if(!error)
        {
            NSLog(@"there is no error");
        }
        else
        {
            NSLog(@"There is something wrong at here.");
        }
    }];

But I am not clear what I have to pass in "object" parameter. Can anybody help to what I am doing wrong at here.

Thanks,

Was it helpful?

Solution

If you read this documentation, it says-

The og.likes action can refer to any open graph object or URL, except for Facebook Pages or Photos.

So, liking a page with Graph API isn't possible.

The only thing you can do- add a Like Button to the page in your app.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top