6

I am developing a iPhone application in which I want to Comment or Like a Photo on Facebook.

For Facebook integration I am using FBConnect and Graph API.

I am getting friends Photos on my wall in my application, now I want to Like or Comment on them through my iPhone Application.

Please suggest me how can i obtain that.

Thanks in Advance.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Apekshit
  • 767
  • 2
  • 13
  • 27

1 Answers1

16

To "Like" a Photo (or everthing else with an ID) just post your Acces-Token to the Graph API, e.g. your photo has the ID 123456789. So you have to post your Access-Token to https://graph.facebook.com/123456789/likes.

To comment on a Photo do the same, but post a message (as a parameter) to the Graph API, e.g. https://graph.facebook.com/123456789/comments.

In Code call the following method (defined in 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

Note, that the httpMethod should be "POST" and the Facebook iOS SDK automaticaly adds your Access-Token.

For more information read the "Publishing" part on: 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 the comments or an empty NSMutableDictionary like:

[NSMutableDictionary dictionary]

if you want to like a post.

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

neowinston
  • 7,584
  • 10
  • 52
  • 83
audience
  • 2,412
  • 21
  • 18
  • Thanks for reply, but this method give us list of like and comment I want to post comment or like on a photo. In the above method -(void) requestWithGraphPath how can i pass the params. – Apekshit Feb 10 '11 at 14:29
  • Just pass this in to the params : `[NSMutableDictionary dictionaryWithObjectsAndKeys:@"This is my comment", @"message", nil];` – deanWombourne Feb 10 '11 at 15:23