问题
Has anyone tried to use the new Facebook SDK to post a comment to an URL? i tried by using startForPostWithGraphPath like this (code snippet picked from Scrumptious project):
id action = [FBGraphObject graphObject];
[action setValue:@"test from iOS app" forKey:@"message"];
// Create the request and post the action to my url path.
[FBRequestConnection startForPostWithGraphPath:@"XXXXXXXXXXXXXXXXXXX/comments"
graphObject:action
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error)
{
NSLog(@"error: %@", error.localizedDescription);
}
else
{
NSLog(@"ok!!");
}
}];
it doesn't work neither from Open Graph API explorer. The error i receive is "an unknown error has occurred", code 200. The XXXXXXXX url is the ID of the page i have comments on, i can read them, but not correctly post to them. Maybe the open graph path is wrong?
回答1:
Hey Friend It's a Good News for you.
I Post the comments and Likes with GraphAPI in IOS
Just write Some code below.
NSMutableDictionary *res = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"This is my comment", @"message", @"Your api's access Token",@"access_token",nil];
[FBRequestConnection startWithGraphPath:@"XXXXXXXXXX/comments" parameters:res HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (error)
{
NSLog(@"error: %@", error.localizedDescription);
}
else
{
NSLog(@"ok!!");
}
}];
XXXXXXXXXX = Id where you want to comment.
Note:-
Please do not appent https://graph.facebook.com
before
XXXXXXXXXX/comments
来源:https://stackoverflow.com/questions/12133603/facebook-ios-sdk-3-0-how-to-make-comment-to-existing-url