如何预先填写在Facebook帖子中写一些文字到朋友的墙上

时间:2014-07-25 15:37:24

标签: ios objective-c facebook-graph-api

您好我正在使用以下代码发布到朋友墙上工作正常。 我想在文本视图中预填充该文本,并在其中写下在朋友的墙上写一些东西。 是否可以编辑它?如果是的话怎么样? 这是代码

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"Sharing Tutorial", @"name",
                               @"Build great social apps and get more installs.", @"caption",
                               @"Allow your users to share stories on Facebook from your app using the iOS SDK.", @"description",
                               @"https://developers.facebook.com/docs/ios/share/", @"link",
                               @"http://i.imgur.com/g3Qc1HN.png", @"picture",
                               @"100006771363037",@"to",
                                nil];

// Show the feed dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
                                       parameters:params
                                          handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
                                            if (error) {
                                              // An error occurred, we need to handle the error
                                              // See: https://developers.facebook.com/docs/ios/errors
                                              NSLog(@"Error publishing story: %@", error.description);
                                            } else {
                                              if (result == FBWebDialogResultDialogNotCompleted) {
                                                // User canceled.
                                                NSLog(@"User cancelled.");
                                              } else {
                                                // Handle the publish feed callback
                                                NSDictionary *urlParams = [self parseURLParams:[resultURL query]];

                                                if (![urlParams valueForKey:@"post_id"]) {
                                                  // User canceled.
                                                  NSLog(@"User cancelled.");

                                                } else {
                                                  // User clicked the Share button

                                                    NSLog(@"fb web dialog result=====>%@",result);
                                                  NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
                                                  NSLog(@"result %@", result);
                                                }
                                              }
                                            }
                                          }];

1 个答案:

答案 0 :(得分:0)

这绝对可能: 将textview的文本设置为所需的预填充文本:

textView.text = @"Allow your users to share stories on Facebook from your app using the iOS SDK.";

并使用textViews的文本作为您要发送到Facebook的词典,也许可以通过一些自定义的方法,如

- (void)postToFacebookWithCaption:(NSString*)caption text:(NSString*)text{
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                           @"Sharing Tutorial", @"name",
                           caption, @"caption",
                           text, @"description",
                           @"https://developers.facebook.com/docs/ios/share/", @"link",
                           @"http://i.imgur.com/g3Qc1HN.png", @"picture",
                           @"100006771363037",@"to",
                            nil];

    //insert code to show the feed dialog
}