我需要通过应用程序向用户的Twitter好友发送带有URL链接的直接消息。使用我当前的代码无法成功发送消息:
public void sendTwitterfriends()
{
HttpClient httpClient = new DefaultHttpClient();
HttpPost request = new HttpPost("https://api.twitter.com/1/direct_messages/new.format");
List<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("user_id", "friendsuserid"));
postParameters.add(new BasicNameValuePair("text", "Hi Testing"));
try {
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(postParameters);
request.setEntity(entity);
HttpResponse response= httpClient.execute(request);
}catch (Exception e) {
// TODO: handle exception
}
}
由于