ios - 有什么方法可以在不显示 ios 中的共享对话框的情况下在 facebook 上共享

标签 ios xcode6 facebook-share

这是我的代码,但 publish_streem 无效。有什么方法可以在 facebook 上分享而不显示 ios 中的分享对话框?

ACAccountStore *accountStore = [[ACAccountStore alloc] init];

ACAccountType *facebookAccountType = [accountStore
                                      accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

//ACAccount *facebookAccount;

// Specify App ID and permissions
NSDictionary *options = @{ACFacebookAppIdKey:@"565048226932112",ACFacebookPermissionsKey:@[@"publish_stream", @"publish_actions"],ACFacebookAudienceKey:ACFacebookAudienceFriends};

[accountStore requestAccessToAccountsWithType:facebookAccountType options:options completion:^(BOOL granted, NSError *error) {
    if (granted) {
        NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];

    }
    else{

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"%@",error] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

        [alert show];
       // NSLog(@"Error :%@",error);
    }
}];

最佳答案

使用 Facebook 图谱 API

https://developers.facebook.com/docs/graph-api/reference/v2.2/post

引用: https://developers.facebook.com/docs/ios/share

//注意:预填与 Facebook 帖子相关的字段, //除非用户在您应用的工作流程中较早地手动生成了内容, //可以违反平台政策:https://developers.facebook.com/policy

//把对话框参数放在一起

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",
                               nil];

// Make the request
[FBRequestConnection startWithGraphPath:@"/me/feed"
                             parameters:params
                             HTTPMethod:@"POST"
                      completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                        if (!error) {
                          // Link posted successfully to Facebook
                          NSLog(@"result: %@", result);
                        } else {
                          // An error occurred, we need to handle the error
                          // See: https://developers.facebook.com/docs/ios/errors
                          NSLog(@"%@", error.description);
                        }
                      }];

关于ios - 有什么方法可以在不显示 ios 中的共享对话框的情况下在 facebook 上共享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29094952/

相关文章:

cocoa-touch - 使用 Swift 的 iOS 应用程序崩溃时只给出 (lldb) 作为输出

ios - 使用swift在六边形中裁剪方形图像

Facebook 分享。更改 "say something more about this",同一页面上的多个按钮

ios - 将相机拍摄的图像上传到服务器 AFNetworking 3.0 时出错

ios - NetworkReachabilityManager 或 Reachability 无法识别在没有互联网的情况下连接 wifi

iOS 5及以上版本: enable landscape mode in MPMoviePlayerController

cocoa-touch - 带有空 UIScrollView 的可滚动内容大小歧义(XCode 6)

android - Facebook 分享按钮已禁用

ios - 在 Facebook 共享中,我无法在 Facebook 应用程序安装情况的 FBLinkShareParams 上发布名称、链接描述和图片

objective-c - 如何在 UIImageView 之间拖放图像并将其居中?