ios - Getting OauthException when uploading a video to facebook -
i trying upload video on iphone user's facebook timeline using social framework. used snippet given in this answer. here code:
- (void)performactivity { nslog(@"sharing on facebook."); acaccountstore *accountstore = [[acaccountstore alloc] init]; acaccounttype *facebookaccounttype = [accountstore accounttypewithaccounttypeidentifier:acaccounttypeidentifierfacebook]; nsdictionary *options = @{acfacebookappidkey : @"***", acfacebookpermissionskey : @[@"email"], acfacebookaudiencekey:acfacebookaudiencefriends}; [accountstore requestaccesstoaccountswithtype:facebookaccounttype options:options completion:^(bool granted, nserror *error) { if (granted) { nsdictionary *options = @{acfacebookappidkey : @"***", acfacebookpermissionskey : @[@"publish_stream"], acfacebookaudiencekey:acfacebookaudiencefriends}; [accountstore requestaccesstoaccountswithtype:facebookaccounttype options:options completion:^(bool granted, nserror *error) { if (granted) { nslog(@"publishing"); acaccount *fbaccount = [accountstore accountswithaccounttype:facebookaccounttype][0]; nsurl *videourl = [nsurl urlwithstring:@"https://graph.facebook.com/me/videos"]; nsurl *pathurl = [nsurl fileurlwithpath:[nsstring stringwithformat:@"%@session.mov", nstemporarydirectory()]]; nsdata *videodata = [nsdata datawithcontentsoffile:[nsstring stringwithformat:@"%@session.mov", nstemporarydirectory()]]; nsdictionary *params = @{ @"title": @"nebuu", @"description": @"mebuu" }; slrequest *uploadrequest = [slrequest requestforservicetype:slservicetypefacebook requestmethod:slrequestmethodpost url:videourl parameters:params]; [uploadrequest addmultipartdata:videodata withname:@"source" type:@"video/quicktime" filename:@"nebuu video"]; uploadrequest.account = fbaccount; [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); }]; }}]; }}]; }
as can see, first requested read permission(email) then, requested publish permission if first request granted. code works fine, permissions granted , app begins uploading video(i can see in network monitoring tool). however, after video uploaded error:
{ "error": { "message": "an unexpected error has occurred. please retry request later.", "type": "oauthexception" } }
what might problem here? read other posts , seems possible thet error originated facebook's side. suggestions?
Comments
Post a Comment