動画ファイルを Facebook に公開したいと考えています。以前は Facebook iOS SDK3.0 を使用していましたが、動作します。ただし、iOS6 Social Framework の場合は問題があります。
__block ACAccount * facebookAccount;
ACAccountStore* accountStore = [[ACAccountStore alloc] init];
NSDictionary *options = @{
ACFacebookAppIdKey: @"MY APP ID",
ACFacebookPermissionsKey: @[@"publish_actions", ],
@"ACFacebookAudienceKey": ACFacebookAudienceFriends
};
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
[accountStore requestAccessToAccountsWithType:facebookAccountType options:options completion:^(BOOL granted, NSError *error) {
if (granted) {
NSArray *accounts = [accountStore
accountsWithAccountType:facebookAccountType];
facebookAccount = [accounts lastObject];
NSLog(@"access to facebook account ok %@", facebookAccount.username);
NSData *videoData = [NSData dataWithContentsOfFile:[self videoFileFullPath]];
NSLog(@"video size = %d", [videoData length]);
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
videoData, @"video.mov",
@"video/quicktime", @"contentType" ,
@"Video title", @"title",
@"Video description", @"description",nil];
NSURL *requestURL = [NSURL URLWithString:@"https://graph.facebook.com/me/videos"];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:requestURL
parameters:params];
request.account = facebookAccount;
[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response,NSError * error){
NSLog(@"response = %@", response);
NSLog(@"error = %@", [error localizedDescription]);
}];
} else {
NSLog(@"access to facebook is not granted");
// extra handling here if necesary
}
}];
キャッチされていない例外 'NSInvalidArgumentException' が原因でアプリを終了しています。理由: '-[NSConcreteData _fastCharacterContents]: 認識されないセレクターがインスタンス 0x2097ead0 に送信されました'