【发布时间】:2014-12-31 11:34:25
【问题描述】:
我正在尝试使用访问令牌在 tumblr 上发布文本。这些访问令牌是从我的 Web 应用程序的 Web 服务中获取的。请帮忙解决这个问题
这是我的代码,它在执行后显示此消息“身份验证错误:无法响应任何这些挑战”
String token = list.get(i).getAccess_token();
String tokenSecret = list.get(i).getAccess_token_secret();
System.out.println("token :"+token);
System.out.println("token secret :"+tokenSecret);
HttpPost hpost = new HttpPost("http://api.tumblr.com/v2/blog/" +list.get(i).getUser_Name()+ ".tumblr.com/post");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("type", "text"));
nameValuePairs.add(new BasicNameValuePair("title", title));
nameValuePairs.add(new BasicNameValuePair("body", body));
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(Tumblr.TUMBLR_CONSUMERKEY, Tumblr.TUMBLR_SECRETKEY);
consumer.setTokenWithSecret(token, tokenSecret);
try {
consumer.sign(hpost);
} catch (OAuthMessageSignerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OAuthExpectationFailedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OAuthCommunicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
DefaultHttpClient client = new DefaultHttpClient();
HttpResponse resp = null;
try {
resp = client.execute(hpost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
【问题讨论】:
-
你有没有相同的解决方案
-
还没有。我还在等答案