我在Facebook上传视频。
我也将此Facebook iOS 3.1 sdk login with publish permission callbacks称为facebook错误。
当我使用Facebook应用程序或从我的应用程序登录时,facebook权限弹出窗口(两者的读取和发布权限)都是打开的,没有发生错误(视频上传成功)。
但之后我从Setting - >登录iPhone的Facebook然后首先要求在facebook权限弹出窗口中打开的alertview中的读取权限。 (如下图所示)之后出现以下错误。
error-> _userInfo:description在nslog中
Printing description of error->_userInfo:
{
"com.facebook.sdk:ErrorInnerErrorKey" = "Error Domain=com.apple.accounts Code=7 \"The Facebook server could not fulfill this access request: no stored remote_app_id for app\" UserInfo=0x234a76b0 {NSLocalizedDescription=The Facebook server could not fulfill this access request: no stored remote_app_id for app}";
}
此代码
-(IBAction)btnFacebookShareClick:(id)sender {
[self StartSpinner];
if (![self openSessionWithAllowLoginUI:YES]) {
[self showLoginView];
}
}
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState)state error:(NSError *)error {
switch (state) {
case FBSessionStateOpen: {
if (self != nil) {
[[FBRequest requestForMe] startWithCompletionHandler: ^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (error) {
//error
}else{
dispatch_async(dispatch_get_current_queue(), ^{
[self openSessionForPublishPermissions];
});
}
}];
}
FBCacheDescriptor *cacheDescriptor = [FBFriendPickerViewController cacheDescriptor];
[cacheDescriptor prefetchAndCacheForSession:session];
}
break;
case FBSessionStateClosed: {
[self StopSpinner];
UIViewController *topViewController = [self.navigationController topViewController];
UIViewController *modalViewController = [topViewController modalViewController];
if (modalViewController != nil) {
[topViewController dismissViewControllerAnimated:YES completion:nil];
}
//[self.navigationController popToRootViewControllerAnimated:NO];
[FBSession.activeSession closeAndClearTokenInformation];
[self performSelector:@selector(showLoginView) withObject:nil afterDelay:0.5f];
}
break;
case FBSessionStateClosedLoginFailed: {
[self StopSpinner];
[self performSelector:@selector(showLoginView) withObject:nil afterDelay:0.5f];
}
break;
default:
break;
}
[[NSNotificationCenter defaultCenter] postNotificationName:SCSessionStateChangedNotificationCamera object:session];
if (error) {
//here error occurred ...
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Error: %@", [CameraViewController FBErrorCodeDescription:error.code]] message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
}
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects: @"email", nil];
return [FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:allowLoginUI completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
-(void)openSessionForPublishPermissions {
if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) {
NSArray *permissions = [[NSArray alloc] initWithObjects: @"publish_actions", nil];
[FBSession.activeSession reauthorizeWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
[self uploadVideoOnFacebook];
}
else {
NSLog(@"%@",error);
}
}];
}
else {
[self uploadVideoOnFacebook];
}
}
-(void) uploadVideoOnFacebook {
NSURL *pathURL;
NSData *videoData;
if (intWhenPushView == 2) {
pathURL = [NSURL fileURLWithPath:self.strUploadVideoURL];
videoData = [NSData dataWithContentsOfFile:self.strUploadVideoURL];
}
else {
pathURL = [NSURL URLWithString:self.strUploadVideoURL];
videoData = [NSData dataWithContentsOfURL:[NSURL URLWithString:self.strUploadVideoURL]];
}
NSString *strDesc;
if ([txtCaption.text isEqualToString:@"Write a caption..."]) {
strDesc = @"";
}
else {
strDesc = txtCaption.text;
}
NSDictionary *videoObject = @{@"title": @"Share60",@"description": strDesc,[pathURL absoluteString]: videoData};
FBRequest *uploadRequest = [FBRequest requestWithGraphPath:@"me/videos" parameters:videoObject HTTPMethod:@"POST"];
[self.view setUserInteractionEnabled:NO];
[uploadRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error)
[AJNotificationView showNoticeInView:self.view type:AJNotificationTypeGreen title:@"Video uploaded successfully" linedBackground:AJLinedBackgroundTypeAnimated hideAfter:3.0];
else
[AJNotificationView showNoticeInView:self.view type:AJNotificationTypeRed title:@"Video uploaded error" linedBackground:AJLinedBackgroundTypeAnimated hideAfter:3.0];
[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(popViewAfterMKInfo) userInfo:nil repeats:NO];
}];
}
请提出建议......并提前感谢。
任何帮助将不胜感激。
答案 0 :(得分:0)
请检查设备设置部分是否有用户登录,如果有用户登录,请检查设备设置中是否可以访问权限 - &gt; faccebook