Facebook iOS SDK 3.0: how to make comment to existing URL?

旧街凉风 提交于 2019-12-09 07:39:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!