1

我正在尝试通过以下方式使用 facebook 帐户进行身份验证

- (IBAction)logInByFaceBook:(id)sender {
    NSLog(@"appDelegate.session.isOpen = %@",appDelegate.session.isOpen == 0 ? @"NO" : @"YES");

    FBSessionLoginBehavior behavior =   FBSessionLoginBehaviorForcingWebView;
    appDelegate.session             =   [[FBSession alloc] init];

    [appDelegate.session  openWithBehavior:behavior 
                         completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
                             NSMutableDictionary     *dict  =   [[NSMutableDictionary alloc] init];

                             [dict setObject:[NSNumber numberWithBool:YES]   forKey:@"didLogIn"];

                             data                           =   [[SavedData alloc] initLogInInfo:dict];
                             [data saveLogInInfoToDisk];

                             if (session.isOpen) {
                                 FBRequest *me              =   [FBRequest requestForMe];
                                 NSLog(@"me is %@",[me description]);

                                 [me startWithCompletionHandler: ^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *my, NSError *error) {
                                     NSLog(@"my is %@",[my description]);
                                  }
                                  ];
                             }
                             [self dismissViewControllerAnimated:YES completion:nil];


                         }
     ];
}

但是,我无法username退缩,控制台正在显示

Error: HTTP status code: 400
my is (null)

通过查找此文档,400 意味着Invalid email address.....并且my为空,因此我根本无法提取username.....

我不知道为什么会发生这种情况...我尝试使用与 facebookSDK 示例代码相同的电子邮件地址,它可以正常工作...

现在迷路了....有人可以指出我做错了什么或遗漏了什么。

4

0 回答 0