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);
}];
はい、ストリームの公開許可がありませんが、どこに配置すればよいかわかりません。このコード全体は、ユーザーがボタンを押したときに呼び出される 1 つのメソッドの下にあります。