3

我需要通过应用程序向用户的 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
      }
}

谢谢

4

0 回答 0