2

我正在使用 commons-codec-1.3 jar linkin-j signpost-core-1.2.1.1 中的 jar

对于 LinkedIn API。它在 Windows 服务器上运行良好。我在 ubuntu 中有相同的代码,但我得到了错误

oAuthService=LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(key, secret);
        request=oAuthService.getOAuthRequestToken("http://www.google.com");

我在 getOAuthRequestToken 上遇到错误

Exception in thread "main" com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: Server returned HTTP response code: 400 for URL: https://api.linkedin.com/uas/oauth/requestToken
    at com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceImpl.getOAuthRequestToken(LinkedInOAuthServiceImpl.java:180)
    at com.cpt.linkedin.linkedINExample.authorize(linkedINExample.java:57)
    at com.cpt.linkedin.linkedINExample.main(linkedINExample.java:38)
Caused by: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: Server returned HTTP response code: 400 for URL: https://api.linkedin.com/uas/oauth/requestToken
    at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:214)
    at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:69)
    at com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceImpl.getOAuthRequestToken(LinkedInOAuthServiceImpl.java:172)
    ... 2 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.linkedin.com/uas/oauth/requestToken
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1458)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1452)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1106)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at oauth.signpost.basic.HttpURLConnectionResponseAdapter.getContent(HttpURLConnectionResponseAdapter.java:18)
    at oauth.signpost.AbstractOAuthProvider.handleUnexpectedResponse(AbstractOAuthProvider.java:228)
    at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:189)
    ... 4 more
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.linkedin.com/uas/oauth/requestToken
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1403)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:397)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
    at oauth.signpost.basic.HttpURLConnectionResponseAdapter.getStatusCode(HttpURLConnectionResponseAdapter.java:22)
    at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:178)
    ... 4 more
4

1 回答 1

2

我终于弄清楚了这个问题。它发生date and time在我的 ubuntu 服务器中。在 ubuntu 中,当我更改为当前日期和时间时,它显示昨天的日期。它工作正常。

于 2013-05-10T10:11:55.643 回答