我正在尝试从我的 Web 应用程序向我的linkedin 发送共享内容,但看起来我做错了什么。
这是我的java代码:
String payload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<share>" +
"<comment>testing</comment>" +
"<visibility><code>anyone</code></visibility>" +
"</share>";
String PROTECTED_RESOURCE_URL = "http://api.linkedin.com/v1/people/~/shares";
OAuthService service = new ServiceBuilder()
.provider(LinkedInApi.class)
.apiKey("XXXXXXXXX")
.apiSecret("XXXXXXXXX")
.debug()
.build();
Scanner in = new Scanner(System.in);
Token requestToken = service.getRequestToken();
// here is for enter the confirmation code while i'm use ooB, use callback in future
System.out.println("Now go and authorize Scribe here:");
System.out.println(service.getAuthorizationUrl(requestToken));
System.out.println("And paste the verifier here");
System.out.print(">>");
Verifier verifier = new Verifier(in.nextLine());
Token accessToken = service.getAccessToken(requestToken, verifier);
OAuthRequest request = new OAuthRequest(Verb.POST, PROTECTED_RESOURCE_URL);
request.addPayload(payload);
service.signRequest(accessToken, request);
Response response = request.send();
一切看起来都在调试控制台中工作,但是当我尝试打印响应正文时,我得到了这个:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
<status>401</status>
<timestamp>1341657286653</timestamp>
<request-id>4STP3FUGSG</request-id>
<error-code>0</error-code>
<message>[unauthorized]. OAU:XXXXXXX|3619482b-ea17-4382-8008-5b108e90c4a2|*01|*01:1341657286:wp7SeE6fAPIj5cSKfd3t+lZfwpE=</message>
</error>
我怎样才能解决这个问题?