我在iOS 5上使用最新的Facebook SDK.我可以使用SSO成功验证用户身份,然后我尝试共享这样的链接:
NSString *appId = [[[NSBundle mainBundle] infoDictionary] objectForKey:TSFacebookAppID]; NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: appId, @"app_id", [url absoluteString], @"link title, @"caption", body, @"description", nil]; [facebook dialog:@"feed" andParams:params andDelegate:self];
我第一次尝试这个时,对话框出现并立即关闭,调用对话框:didFailWithError:错误委托方法.错误是:
错误域= NSURLErrorDomain代码= -999"操作无法完成.(NSURLErrorDomain错误-999.)"UserInfo = 0x98f2ab0 {NSErrorFailingURLKey = https://m.facebook.com/dialog/feed?link=http%3A %2F%2Fwww.thescore.com%2Fhome%2Farticles%2F184248&描述=纳达尔%20pulls%20out%20of%20Paris%20to%20focus%20on%20ATP%20finals&的access_token = BAABw00HZB06cBALT57lZCM24N4EOtPpOQeCgl7oLUvbHFR0ZAlwgAbPHQ7HANmlBE0aUKVNDmWNYsEqB0wXq28vm4D18T5hLTVDK3x2WjnVjgIVl75RPoOszSB21f4ZD&字幕=文章%20from%20ScoreMobile%20for%20iPhone&APP_ID = 124052647629735&REDIRECT_URI = fbconnect %3A%2F%2Fsuccess&sdk = 2&display = touch,NSErrorFailingURLStringKey = https://m.facebook.com/dialog/feed?link=http%3A%2F%2Fwww.thescore.com%2Fhome%2Farticles%2F184248&description=Nadal%20pulls %20out%20of%20Paris%20to%20focus%20on%20ATP%20finals&=的access_token&BAABw00HZB06cBALT57lZCM24N4EOtPpOQeCgl7oLUvbHFR0ZAlwgAbPHQ7HANmlBE0aUKVNDmWNYsEqB0wXq28vm4D18T5hLTVDK3x2WjnVjgIVl75RPoOszSB21f4ZD字幕=文章%20from%20ScoreMobile%20for%20iPh one&app_id = 124052647629735&redirect_uri = fbconnect%3A%2F%2Fsuccess&sdk = 2&display = touch }
但是,随后尝试共享链接工作正常.
只是每个人的更新,它最终分配给Facebook的某个人:https://developers.facebook.com/bugs/168127053284477 - 希望它很快就会修复.
同时,有人在github上发送了一个带有修复程序的pull请求:https://github.com/facebook/facebook-ios-sdk/pull/436
希望它可以帮助某人,因为我仍然面临同样的错误..
在尝试调出facebook post窗口时,我偶尔也会得到这个-999 NSURLDomainError.我在评论中采用了忽略错误代码的策略,如高级提及的那样.
我不觉得这个问题的原因是FBLoginDialog实际上已经忽略了这个错误.看看github中的代码:
https://github.com/facebook/facebook-ios-sdk/blob/master/src/FBLoginDialog.m#L85
所以具体来说,这就是我的webView:didFailLoadWithError方法现在在FBDialog.m中的样子:
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { // 102 == WebKitErrorFrameLoadInterruptedByPolicyChange NSLog(@"FBDialog webView didFailLoadWithError:%@ %d",error.domain,error.code); if ([error.domain isEqualToString:@"NSURLErrorDomain"] && error.code == -999) return; if ([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102) return; [self dismissWithError:error animated:YES]; }