iOS:如何使用SDK在没有安装Facebook应用程序的情况下在Facebook上共享本地图像?

时间:2017-10-24 13:45:52

标签: ios objective-c facebook share facebook-sdk-4.x

我使用这些代码发布图片但没有成功:

按钮上的代码点击:

  FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
    photo.image = [UIImage imageNamed:@"Select.png"];
    photo.userGenerated = YES;
    FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
        content.photos = @[photo];
        content.imageURL //property in read only
        [FBSDKShareDialog showFromViewController:self withContent:content delegate:self];

说明:

我安装了SDF facebook,我把键放在plist中,我把appDelegate函数和#import放在我的主viewController中。我添加了一个按钮,然后在按钮事件中添加了一段代码。

错误讯息:

  -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
[core] SLComposeViewController initWithServiceType: com.apple.social.facebook
[core] SLComposeViewController initWithServiceType got extension (null) for identifier com.apple.share.Facebook.post
[core] SLComposeViewController initWithExtension: (null) requestedServiceType: com.apple.social.facebook
-canOpenURL: failed for URL: "fbapi20150629:/" - error: "This app is not allowed to query for scheme fbapi20150629"
-canOpenURL: failed for URL: "fbshareextension:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
[core] addImage start
[core] viewWillAppear
[core] viewDidAppear
[core] ViewDidAppear, but remote VC failed, dismissing
[core] Sheet not being presented, calling premature completion
[core] SLComposeViewController completeWithResult: 0
[core] SLComposeViewController automatically dismissing itself
[core] SLComposeViewController dealloc <SLComposeViewController: 0x105644ed0>

OR:

//Facebook
FBSDKShareLinkContent *content2 = [[FBSDKShareLinkContent alloc] init];

content2.contentURL = [NSURL URLWithString:@"https://www.facebook.com/FacebookDevelopers"];
FBSDKShareButton *shareButton = [[FBSDKShareButton alloc] init];
shareButton.shareContent = content2;
shareButton.center = self.view.center;

[self.view addSubview:shareButton];

提前致谢。

0 个答案:

没有答案