gpt4 book ai didi

ios - 如何在不使用 native ios应用程序的FBSDKShareDialog的情况下在Facebook墙上共享照片或链接

转载 作者:行者123 更新时间:2023-12-01 16:09:25 25 4
gpt4 key购买 nike

我想在不使用FBSDKShareDialog的情况下在用户Facebook墙上发布一些照片或链接。我已经使用来自Facebook的FBSDKSharePhoto和FBSDKShareDialog默认对话框发布了。为此,我执行以下代码

FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = self.imgView.image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:(id)self];

但是,此代码将打开“默认FB”对话框。因此,如何直接在用户墙上发布链接和照片。

最佳答案

您可以使用默认iOS社交框架的SLComposeViewController

#import <Social/Social.h>

- (IBAction)postToFacebook:(id)sender {
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

[controller setInitialText:@"Post from my iPhone app"];
[controller addURL:[NSURL URLWithString:@"http://www.yourlink.com"]];
[controller addImage:[UIImage imageNamed:@"facebook-image.jpg"]];
[controller setCompletionHandler:^(SLComposeViewControllerResult result) {

switch (result) {
case SLComposeViewControllerResultCancelled:
NSLog(@"Post Canceled");
break;
case SLComposeViewControllerResultDone:
NSLog(@"Post Sucessful");
break;

default:
break;
}
}];
[self presentViewController:controller animated:YES completion:Nil];

}
}

Facebook共享文档。 : https://developers.facebook.com/docs/sharing/ios

通过图谱API:

1) Post image on facebook wall using graph api iphone sdk

2) Photo Upload to own wall via iOS Graph API with user's location

3) http://www.raywenderlich.com/1488/facebook-tutorial-for-ios-how-to-use-facebook-new-graph-api-from-your-iphone-app

关于ios - 如何在不使用 native ios应用程序的FBSDKShareDialog的情况下在Facebook墙上共享照片或链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30779597/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com