我正试着用FacebookSDK在我的fb中发布一条信息或分享一张照片。我已经遵循了如何安装它的步骤。我已经完成了应用登录教程的工作,但是现在的问题是如何通过我的应用程序将消息发布或共享到我的FB中。有很多类似这个一的教程。我认为这对FacebookSDK来说已经很老了。抱歉,如果我对这件事太没兴趣了。我知道这不是发布这篇文章的合适页面,但我现在不知道。如果您有关于如何发布或共享的教程。请给我链接。如果有的话,你能提供这方面的步骤。
我已经尝试过这,但它没有发布或共享。
UPdate
这是我的密码
import "ShareController.h"
#import <FBSDKShareKit/FBSDKShareKit.h>
#import <FBSDKMessengerShareKit/FBSDKMessengerShareKit.h>
@implementation ShareController
- (void)viewDidLoad {
[super viewDidLoad];
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:@"https://developers.facebook.com"];
FBSDKShareButton *button = [[FBSDKShareButton alloc] init];
button.shareContent = content;
[self.view addSubview:button];
}
- (IBAction)shareButton:(id)sender {
UIImage * image = [UIImage imageNamed:@"sample.png"];
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = image;
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = self;
dialog.shareContent= content;
dialog.mode = FBSDKShareDialogModeShareSheet;
[dialog show];
}这是我登录的密码。我认为这是一个简单的代码
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.center = self.view.center;
[self.view addSubview:loginButton];
// Do any additional setup after loading the view, typically from a nib.
}发布于 2016-02-19 04:49:33
您没有设置权限,以设置权限:
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.center = self.view.center;
[loginButton logInWithPublishPermissions: @[@"publish_actions"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Process error");
} else if (result.isCancelled) {
NSLog(@"Cancelled");
} else {
NSLog(@"Logged in");
}
}];此外,检查用户是否在IBAction方法中授予了该权限也是一个很好的做法:
- (IBAction)shareButton:(id)sender {
if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"])
{
// code to share
}
}

https://stackoverflow.com/questions/35497325
复制相似问题