简体   繁体   English

如何从 IOS 应用程序在好友墙上发布 Facebook Feed?

[英]How to post Facebook Feed on Friends wall from IOS application?

如何从 IOS 应用程序在好友墙上发布Facebook Feed

  • Social Framework is very uch useful for sharing and posting in Fb,Twitter .社交框架对于在 Fb、Twitter 中共享和发布非常有用。
  • Here in the dialog it will ask for privacy we can set that to friends/Piblic/Me在对话框中,它会要求隐私,我们可以将其设置为朋友/Piblic/我

     if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { // Initialize Compose View Controller SLComposeViewController *vc = nil; vc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; // Configure Compose View Controller [vc setInitialText:self.captionTextField.text]; [vc addImage:self.image]; [vc setCompletionHandler:^(SLComposeViewControllerResult result){ if (result == SLComposeViewControllerResultDone) { [[[UIAlertView alloc] initWithTitle:@"Congratulations" message:@"Your post is successfully Posted" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] show]; }else{ } }]; // Present Compose View Controller [self presentViewController:vc animated:YES completion:nil]; } else { NSString *message = @"It seems that we cannot talk to Facebook at the moment or you have not yet added your Facebook account to this device. Go to the Settings application to add your Facebook account to this device."; UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops" message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; }

Via Graph API you cannot post to the friend's wall, it was deprecated.通过 Graph API 你不能发布到朋友的墙上,它已被弃用。

You can use Feed Dialog to invoke the dialog and user can post the feed to any friend, here's the code:您可以使用Feed Dialog来调用该对话框,用户可以将 Feed 发布给任何朋友,代码如下:

NSMutableDictionary *params =
    [NSMutableDictionary dictionaryWithObjectsAndKeys:
        @"An example parameter", @"description",
        @"https://developers.facebook.com/ios", @"link",
        nil];

[FBWebDialogs presentFeedDialogModallyWithSession:nil
    parameters:params
    handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {}
];

Check documentation for more details and list of parameters available.查看文档以获取更多详细信息和可用参数列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM