How to comment or like a photo in facebook through FBconnect or Graph API in iPhone SDK?

前端 未结 1 1596
耶瑟儿~
耶瑟儿~ 2020-12-09 13:51

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

相关标签:
1条回答
  • 2020-12-09 14:35

    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.

    0 讨论(0)
提交回复
热议问题