How to comment or love facebook photo via FBconnect or Graph API in iPhone SDK?

I am developing an application for the iPhone in which I want to comment or as a photo on Facebook.

For integration with Facebook, I use the FBConnect and Graph APIs.

I get photos of friends on my wall in my application, now I want to like or comment on them through the iPhone application.

Please suggest me how I can get this.

Thanks at Advance.

+6
ios facebook facebook-graph-api facebook-ios-sdk
source share
1 answer

To β€œlike” a photo (or still with an identifier), simply place your token token in the Graph API, for example. your photo has ID 123456789. Therefore, you must publish your access token at https://graph.facebook.com/123456789/likes .

To comment on a photo, do the same, but post the message (as a parameter) in the Graph API, for example. https://graph.facebook.com/123456789/comments .

In a code call, the following method (defined on Facebook.h) with your path and no parameters for β€œLike” and a message as a parameter for β€œComment”:

-(void) requestWithGraphPath:(NSString *)graphPath andParams:(NSMutableDictionary *)params andHttpMethod:(NSString *)httpMethod andDelegate:(id <FBRequestDelegate>)delegate 

Please note that httpMethod must be "POST" and the iOS SDK file automatically adds your access token.

For more information, read the "Publishing" section at: http://developers.facebook.com/docs/reference/api

Edit: Like deanWombourne wrote in the comments: Just post an NSMutableDictionary like this

 [NSMutableDictionary dictionaryWithObjectsAndKeys:@"This is my comment", @"message", nil]; 

for comments or an empty NSMutableDictionary, for example:

 [NSMutableDictionary dictionary] 

if you want to like the message.

The response from the Facebook servers should be result = true.

+16
source share

All Articles