如何在Facebook中通过FBconnect或Graph API在iPhone SDK中评论或喜欢照片? [英] How to comment or like a photo in facebook through FBconnect or Graph API in iPhone SDK?
问题描述
我正在开发一个iPhone应用程序,其中我想评论或像Facebook上的照片。
I am developing a iPhone application in which I want to Comment or Like a Photo on Facebook.
对于Facebook集成,我使用的是FBConnect和Graph API。
For Facebook integration I am using FBConnect and Graph API.
我正在获得朋友照片在我的应用程序的墙上,现在我想通过我的iPhone应用程序喜欢或评论他们。
I am getting friends Photos on my wall in my application, now I want to Like or Comment on them through my iPhone Application.
请建议我如何获得。
感谢提前。
推荐答案
为了喜欢一张照片(或其他任何ID),只需将您的Acces-Token发布到Graph API,例如您的照片的身份是123456789.因此,您必须将您的访问令牌发布到 https://graph.facebook .com / 123456789 / likes 。
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.
要对照片进行评论,请执行相同操作,但会向Graph API发布消息(作为参数),例如 https://graph.facebook.com/123456789/comments 。
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.
在代码中,使用您的路径调用以下方法(在Facebook.h中定义),没有Like的参数以及作为Comment参数的消息:
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
注意,httpMethod应该是POST,Facebook iOS SDK会自动添加您的访问令牌。
Note, that the httpMethod should be "POST" and the Facebook iOS SDK automaticaly adds your Access-Token.
有关更多信息,请阅读发布部分: http://developers.facebook.com/docs/reference/api
For more information read the "Publishing" part on: http://developers.facebook.com/docs/reference/api
编辑:
喜欢deanWombourne在评论中写道:Just post a NSMutableDictionary like this
Like deanWombourne wrote in the comments: Just post an NSMutableDictionary like this
[NSMutableDictionary dictionaryWithObjectsAndKeys:@"This is my comment", @"message", nil];
用于评论或空的NSMutableDictionary,如:
for the comments or an empty NSMutableDictionary like:
[NSMutableDictionary dictionary]
如果你想喜欢一个帖子。
if you want to like a post.
来自Facebook服务器的响应应该是result = true。
The response from the Facebook servers should be result = true.
这篇关于如何在Facebook中通过FBconnect或Graph API在iPhone SDK中评论或喜欢照片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!