2012-08-24 73 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? –