esme-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Hirsch <hirsch.d...@gmail.com>
Subject Re: How to update a ESME status with a Java application?
Date Thu, 14 Jan 2010 06:55:29 GMT
One more thing: the username isn't the user's email but rather the user-id

On Thu, Jan 14, 2010 at 7:54 AM, Richard Hirsch <hirsch.dick@gmail.com> wrote:
> You need to use the token instead of the user's password.
>
> Here is the help page from the Web Ui with details on how to do it:
> http://cwiki.apache.org/ESME/web-ui-help.html -- just search for the
> word "Manage Tokens"
>
> D.
>
>
> On Thu, Jan 14, 2010 at 7:28 AM, Chatree Srichart
> <chatree.srichart@gmail.com> wrote:
>> 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
View raw message