0

我把视频上传到脸书。

我还参考了这个 Facebook iOS 3.1 sdk login 以及 Facebook 错误的发布权限回调

当我使用 Facebook 应用程序或从我的应用程序登录时,facebook 权限弹出窗口(读取和发布权限都)打开并且没有发生错误(视频上传成功)。

在此处输入图像描述

但在那之后,我从 iPhone 的 Setting -> Facebook 登录,然后首先它在 alertview 中请求读取权限,而不是在 facebook 权限弹出窗口中打开。(如下图所示),然后给出以下错误。 在此处输入图像描述 在此处输入图像描述

错误->_userInfo:描述在 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];
    }];
}

请提出建议......并提前感谢。

任何帮助将不胜感激。

4

1 回答 1

0

请在设备设置部分检查是否有任何用户登录,如果有用户登录,则在设备设置->脸书中检查权限是否可访问

于 2013-04-26T12:47:30.857 回答