Here I am posting some text from an Android app to a user's Twitter account, and I have ConsumerKey, Consumer secret key, AccessToken, and AccessToken secret key.
https://api.twitter.com/1.1/statuses/update.json
By using simple a HTTP client request, I want to post data on a Twitter user account. How can I do that?
I tried something like
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
}
But parameters are wrong in my code, following this, but I didn't get it so what is some suitable solution for this?