我只是想将 Facebook 分享整合到我的应用程序中,我的应用程序的最终产品是一个视频,因此上传并与朋友分享最终编译是我的想法,我正在使用本地社交框架和 ACAccount 框架,让我的应用程序工作Facebook 似乎有一个奇怪的逻辑,我需要在我请求 publish_stream 权限之前请求读取权限,并且他们不能立即(在某处读取),我的问题是我应该在哪里以及如何在我的代码中实现这个逻辑,继承人我的代码
ACAccountStore* accountStore = [[ACAccountStore alloc] init];
NSDictionary *options = @{
ACFacebookAppIdKey: @"My app ID",
ACFacebookPermissionsKey: @[@"user_birthday"],
ACFacebookAudienceKey: ACFacebookAudienceOnlyMe
};
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
[accountStore requestAccessToAccountsWithType:facebookAccountType options:options completion:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *accounts = [accountStore
accountsWithAccountType:facebookAccountType];
ACAccount * facebookAccount = [accounts lastObject];
NSLog(@"access to facebook account ok %@", facebookAccount.username);
NSData *videoData = [NSData dataWithContentsOfFile:[_fURL absoluteString]];
NSLog(@"%@",[_fURL absoluteString]);
NSLog(@"video size = %d", [videoData length]);
NSDictionary *params = @{
@"title": @"Me being silly",
@"description": @"Me testing the video upload to Facebook with the new system."
};
NSURL *requestURL = [NSURL URLWithString:@"https://graph.facebook.com/me/videos"];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:requestURL
parameters:params];
[request addMultipartData:videoData
withName:@"source"
type:@"video/quicktime"
filename:[_fURL absoluteString]];
request.account = facebookAccount;
[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response,NSError * error){
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"response = %@", responseString);
}];
是的,我缺少发布流权限,但我似乎无法弄清楚我应该把它放在哪里,整个代码都在用户按下按钮时调用的一种方法下