esme-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chatree Srichart <chatree.srich...@gmail.com>
Subject How to update a ESME status with a Java application?
Date Thu, 14 Jan 2010 06:28:02 GMT
Hi, all

I try to update a ESME status with a Java application.

=== Java Code ===

String twitterUrl = "http://localhost:8080/twitter/statuses/update.xml";
String username = "myUserName@email.com";
String password = "myPassword";

OutputStreamWriter writer = null;
String statusMessage = "Test Status";

 try {
        URL url = new URL(twitterUrl);
        HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
        connection.setDoOutput(true);
        String authorization = username + ":" + password;
        String encoding = Base64.base64Encode(authorization);
        connection.setRequestProperty("Authorization", "Basic " +
encoding.getBytes());

        String encStatus = "status=" + URLEncoder.encode(statusMessage,
"UTF-8");
        writer = new OutputStreamWriter(connection.getOutputStream());
        writer.write(encStatus);
        writer.flush();

        int responseCode = connection.getResponseCode();
        System.out.println("responseCode:" + responseCode);
    } catch (Exception e) {
        e.printStackTrace();
    }

==============
But I get 401 as response code. It look like authentication fail.
Can any one tell me what I was wrong and where is ESME document I have to
look for updating status form a Java application?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message