【发布时间】:2014-02-21 03:49:58
【问题描述】:
在这里,我将一些文本从 Android 应用程序发布到用户的 Twitter 帐户,并且我有 ConsumerKey、Consumer 密钥、AccessToken 和 AccessToken 密钥。
https://api.twitter.com/1.1/statuses/update.json
通过使用简单的 HTTP 客户端请求,我想在 Twitter 用户帐户上发布数据。我该怎么做?
我尝试了类似的东西
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://api.twitter.com/1/statuses/update.json");
// HttpPost httppost = new HttpPost("https://graph.facebook.com/" + profile_ID + "/feed");
System.out.println("httppost " + httppost);
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("access_token", access_token_value));
nameValuePairs.add(new BasicNameValuePair("message", compose.getText().toString()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
System.out.println("response "+response.toString());
}
catch (ClientProtocolException e) {
// TODO Auto-generated catch block
}
catch (IOException e) {
// TODO Auto-generated catch block
}
但我的代码following this 中的参数有误,但我没有得到它,那么有什么合适的解决方案呢?
【问题讨论】:
-
请检查下面的答案,谢谢。
-
是的,它要求登录。但我想在没有登录的情况下发布应用数据
-
@SalmanAyub twitter4j 是任何人的首选,根据我的要求在没有登录的情况下使用 twitter 我想从我的应用程序和上面的信息中发布推文,我没有通过使用上面的信息如何发帖