我正在尝试使用新的(测试版)ios sdk 3.0在一个应用程序中添加Facebook集成.所有我想要发布的状态更新到Facebook.我用FBLoginView登录到Facebook.我把我的应用程序id放在plist的指示在Facebook上.我把一些代码发贴到Facebook.
(void)viewDidLoad { [super viewDidLoad]; NSArray *perms; perms = [NSArray arrayWithObjects:@"status_update",nil]; FBLoginView *loginview = [[FBLoginView alloc] initWithPermissions:perms]; loginview.frame = CGRectOffset(loginview.frame,5,5); loginview.delegate = self; [self.view addSubview:loginview]; // Do any additional setup after loading the view,typically from a nib. } - (IBAction)poststatus:(UIButton *)sender { NSString *message = [NSString stringWithFormat:@"Test staus update"]; [FBRequestConnection startForPostStatusUpdate:message completionHandler:^(FBRequestConnection *connection,id result,NSError *error) { [self showAlert:message result:result error:error]; }]; } - (void)showAlert:(NSString *)message result:(id)result error:(NSError *)error { NSString *alertMsg; NSString *alertTitle; if (error) { alertMsg = error.localizedDescription; alertTitle = @"Error"; } else { NSDictionary *resultDict = (NSDictionary *)result; alertMsg = [NSString stringWithFormat:@"Successfully posted '%@'.\nPost ID: %@",message,[resultDict valueForKey:@"id"]]; alertTitle = @"Success"; } UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:alertTitle message:alertMsg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; }
奇怪的是,这段代码可以一直工作.第一次验证用户后,我可以成功发送一个状态更新.之后,所有后续尝试将失败,并显示FBiOSSDK错误5(在控制台中,错误:HTTP状态代码为400).解决此问题的唯一方法是从Facebook帐户中删除该应用程序并重新验证.我不知道问题是什么.我在网上查找解决方案,但找不到任何东西.如果有人知道如何解决这个问题,请让我知道.谢谢