I'm using the social framework in iOS 6 to integrate facebook video uploading into my app. However, nothing happens when I run the program, and I instead receive these errors:
The operation couldn’t be completed. (com.apple.accounts error 6.)
"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}"
Below is my code, the first half of which I implemented from this tutorial. granted
is set to false
, causing the first error.
- (void)uploadToFb {
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *facebookAccountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
// Specify App ID and permissions
NSDictionary *options = @{
ACFacebookAppIdKey: @"2************",
ACFacebookPermissionsKey: @[@"publish_stream", @"publish_actions"],
ACFacebookAudienceKey: ACFacebookAudienceFriends
};
[accountStore requestAccessToAccountsWithType:facebookAccountType
options:options completion:^(BOOL granted, NSError *e) {
if (granted)
{
NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];
facebookAccount = [accounts lastObject];
}
else
{
NSLog(@"Error %@", e.localizedDescription); }
}
}];
NSURL *videourl = [NSURL URLWithString:@"https://graph.facebook.com/me/videos"];
NSString *filePath = [outputURL path];
NSURL *pathURL = outputURL;
NSData *videoData = [NSData dataWithContentsOfFile:filePath];
NSDictionary *params = @{
@"title": @"Face Puppets Video",
@"description": @"A funny video I made with the #FacePuppets iOS app."
};
SLRequest *uploadRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodPOST
URL:videourl
parameters:params];
[uploadRequest addMultipartData:videoData
withName:@"source"
type:@"video/quicktime"
filename:[pathURL absoluteString]];
uploadRequest.account = facebookAccount;
[uploadRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
if(error){
NSLog(@"Error %@", error.localizedDescription);
}else
NSLog(@"%@", responseString);
}];
}
Hi Here it is a very nice Sharing example iOS (Wiki) (Sample Project for iOS, ~3 MB) Using this you can share Video in to Facebook, YouTube, Flicker, Vimeo Take a look above link and test this Example.
You need to set You
AppId
in toESSViewController.m
class In this Method:Might Be this is an Old virsion of Facebook but for getting Idea about how to process for share Video from ourApp.