我正在尝试使用foursquare api登录foursquare。它正在显示登录页面,但崩溃时,我试图输入用户名或密码。它在几天前工作得很好,但突然停止了工作。
Server responded with:400, bad request
2012-08-24 14:44:25.227[1962:17903] contant data {"error":"invalid_grant"}
2012-08-24 14:44:25.228[1962:17903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: foursquare_access_token)'请帮帮我。为什么会出现这个错误?
发布于 2012-08-25 04:56:07
Foursquare登录页面现在返回来自Facebook网站的请求。因此,您可以使用FB凭据登录Foursquare。
这些响应之一会停止Foursquare2逻辑https://s-static.ak.facebook.com/connect/xd_arbiter.php?version=10#cb=xxx&origin=https%3A%2F%2Ffoursquare.com%2Fxxx&domain=foursquare.com&relation=parent&frame=xxx&error=unknown_user
Foursquare2在响应中查找"error=“。如果找到它,它会执行委托回调。
要修复它,请替换您的‘webView:shouldStartLoadWithRequest:navigationType:’
在Foursquare2.m中
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSString *url =[[request URL] absoluteString];
if ([url rangeOfString:@"facebook.com"].location != NSNotFound)
return YES; //ignore Facebook authentication
if ([url rangeOfString:@"code="].length != 0) {
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]) {
if ([[cookie domain]isEqualToString:@"foursquare.com"]) {
[storage deleteCookie:cookie];
}
}
NSArray *arr = [url componentsSeparatedByString:@"="];
[delegate performSelector:selector withObject:[arr objectAtIndex:1]];
[self cancel];
}else if ([url rangeOfString:@"error="].length != 0) {
NSArray *arr = [url componentsSeparatedByString:@"="];
[delegate performSelector:selector withObject:[arr objectAtIndex:1]];
FourSquareLog(@"Foursquare: %@",[arr objectAtIndex:1]);
}
return YES;
}请注意一个新的
if ([url rangeOfString:@"facebook.com"].location != NSNotFound)
return YES; //ignore Facebook authentication发布于 2012-08-24 17:26:29
获取您自己的密钥、消费者密钥和密钥,以便在oauth上应用
在具有用于应用程序更新或替换的使用者密钥和密钥之后
Constants.h file of your pojecthttps://stackoverflow.com/questions/12106465
复制相似问题