2012-08-24 60 views
1

我正在尝试使用foursquare API登录foursquare。它显示登录页面,但在尝试输入用户名或密码时崩溃。几天前它运转良好,但突然停止工作。Foursqaure2 API V2登录错误

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)' 

请帮帮我。为什么这个错误即将到来?

回答

0

获取YOUT自己的oauth

主要的消费密钥和密码应用有消费者对应用程序更新密钥和密码后或

Constants.h file of your poject 
3

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&误差= unknown_user

Foursquare2正在寻找的 “错误=” 的。如果发现它,它会执行委托回叫。

要修复它取代你 'web视图: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 
+0

谢谢您的回答是很有帮助。我想知道,如何使用facebook按钮登录才能正常工作?用您的解决方案,一旦我按下按钮屏幕变空白,没有加载。 – NullSleep

+0

但如果我不想忽略Facebook身份验证会怎么样?我想从Facebook登录foursquare? –