如何通过iPhone SDK中的FBconnect或Graph API评论或喜欢Facebook中的照片?

Ape*_*hit 6 facebook facebook-graph-api ios facebook-ios-sdk

我正在开发一个iPhone应用程序,我想在Facebook上评论或喜欢照片.

对于Facebook集成,我使用的是FBConnect和Graph API.

我在我的应用程序中获取朋友的照片,现在我想通过我的iPhone应用程序喜欢或评论它们.

请建议我如何获得.

提前致谢.

aud*_*nce 16

要"喜欢"一张照片(或其他带有ID的照片),只需将你的Acces-Token发布到Graph API,例如你的照片的ID为123456789.所以你必须将你的Access-Token发布到https://graph.facebook .com/123456789/likes.

要对Photo发表评论,请将相关消息(作为参数)发布到Graph API,例如https://graph.facebook.com/123456789/comments.

在代码中使用您的路径调用以下方法(在Facebook.h中定义),没有"Like"参数和消息作为"Comment"的参数:

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

请注意,httpMethod应为"POST",Facebook iOS SDK会自动添加您的Access-Token.

有关更多信息,请阅读"发布"部分:http://developers.facebook.com/docs/reference/api

编辑:像deanWombourne在评论中写道:只需发布一个像这样的NSMutableDictionary

[NSMutableDictionary dictionaryWithObjectsAndKeys:@"This is my comment", @"message", nil];
Run Code Online (Sandbox Code Playgroud)

对于评论或空的NSMutableDictionary,如:

[NSMutableDictionary dictionary]
Run Code Online (Sandbox Code Playgroud)

如果你想要一个帖子.

Facebook服务器的响应应为result = true.