2012-10-07 19 views
1

在LinkedIn上更新狀態,我使用下面的代碼沒能在iPhone上

- (void)linkedInEngineAccessToken:(RDLinkedInEngine *)engine setAccessToken:(OAToken *)token { 
     if(token) { 
      [token rd_storeInUserDefaultsWithServiceProviderName:@"LinkedIn" prefix:@"My app name"]; 
     } 
     else { 
      [OAToken rd_clearUserDefaultsUsingServiceProviderName:@"LinkedIn" prefix:@"My App name"]; 

     } 
    } 

    - (OAToken *)linkedInEngineAccessToken:(RDLinkedInEngine *)engine { 
     return [OAToken rd_tokenWithUserDefaultsUsingServiceProviderName:@"LinkedIn" prefix:@"My app name"]; 
    } 

    - (void)linkedInEngine:(RDLinkedInEngine *)engine requestSucceeded:(RDLinkedInConnectionID *)identifier withResults:(id)results { 
     NSLog(@"++ LinkedIn engine reports success for connection %@\n%@", identifier, results); 
     if(identifier == self.fetchConnection) { 
     // NSDictionary* profile = results; 

     } 
    } 

    - (void)linkedInEngine:(RDLinkedInEngine *)engine requestFailed:(RDLinkedInConnectionID *)identifier withError:(NSError *)error { 
     NSLog(@"++ LinkedIn engine reports failure for connection %@\n%@", identifier, [error localizedDescription]); 
    } 

    - (void)fetchProfile { 
     self.fetchConnection = [self.engine profileForCurrentUser]; 
     [self.engine updateStatus:@"Download app from the #Apple #AppStore and #Android #GooglePlay market."]; 
     [self dismissModalViewControllerAnimated:YES]; 
    } 

    #pragma mark - RDLinkedInAuthorizationControllerDelegate 

    - (void)linkedInAuthorizationControllerSucceeded:(RDLinkedInAuthorizationController *)controller { 
     [self fetchProfile]; 
    } 

    - (void)linkedInAuthorizationControllerFailed:(RDLinkedInAuthorizationController *)controller { 

    } 

    - (void)linkedInAuthorizationControllerCanceled:(RDLinkedInAuthorizationController *)controller { 

    } 


    @end 

我已正確設置的東西。它帶我到LinkedIn登錄頁面,登錄後的權限給予我得到這個錯誤

無法加載頁面錯誤域= NSURLErrorDomain代碼= -1003「A 服務器指定主機名無法找到。」 的UserInfo = 0x81e2250 {NSErrorFailingURLStringKey = HTTP://www.devbee.ca/組oauth_token = MY_TOKEN & oauth_verifier = VERIFIER, NSErrorFailingURLKey = MY_REDIRECT_URL /組oauth_token = MY_OAUTH_TOKEN & oauth_verifier = MY_VERIFIER, NSLocalizedDescription =與指定的主機名的服務器?不能 發現,NSUnderlyingError = 0x810ddc0「與指定 主機服務器無法找到。」}

有什麼不對?

是不是因爲

- (OAToken *)linkedInEngineAccessToken:(RDLinkedInEngine *)engine { 
      return [OAToken rd_tokenWithUserDefaultsUsingServiceProviderName:@"LinkedIn" prefix:@"My app name"]; 
     } 

回答

1

問題來自於http://www.devbee.ca未啓動並運行的事實。我不知道你的代碼或配置中的哪一點是指http://www.devbee.ca,但這就是錯誤所在。

我猜測在LinkedIn App的配置中,您已將OAuth Accept Redirect URL設置爲http://www.devbee.ca,這是一個不存在的URL。但這只是一個猜測,你需要仔細研究爲什麼LinkedIn將你重定向到http://www.devbee.ca

更新

看來你需要設置的OAuth接受重定向URL在您的應用程序的配置http://linkedin_oauth/success。它指出這在如何在GitHub project

最重要的是,OAuth的重定向URL必須設置爲: http://linkedin_oauth/success爲Web視圖的是 通知

+0

LinkedIn委託redirets我這個因爲在設置中這是因爲Callbackurl。但我不知道如何在iphone –

+0

中設置回調網址我相信我找到了答案,我更新了我的回覆。 –

0

由於URL連接錯誤,它與您的重定向URL的一個問題。

看,錯誤說:"A server with the specified hostname could not be found"。這意味着您沒有連接互聯網,或者您的服務器主機名未在您的提供商的DNS列表中找到,或者您的服務器URL錯誤。

你可以試試。該錯誤指定了錯誤url:"NSErrorFailingURLKey=MY_REDIRECT_URL/?oauth_token=MY_OAUTH_TOKEN&oauth_verifier=MY_VERIFIER"。您可以嘗試在Mac上的Safari/Chrome /等中打開指定的網址"MY_REDIRECT_URL/?oauth_token=MY_OAUTH_TOKEN&oauth_verifier=MY_VERIFIER",然後看看會發生什麼。如果您發現同樣的錯誤,請仔細檢查重定向網址。如果成功打開,則iOS應用程序出現問題。