views:

57

answers:

1
URL url = new URL("http://twitter.com/statuses/update.xml");

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);

String cridentials =
    new sun.misc.BASE64Encoder().encode((username + ":" + password).getBytes());

conn.setRequestProperty ("Authorization", "Basic " + cridentials);

OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(status);
wr.flush();
wr.close();

Why is above code for updating twitter status is not working ?

I am running it on google app engine.

+2  A: 

You'll find this easier if you the java twitter library. Even if you don't use it, you can read it and see how to do this much more straightforwardly with Apache Commons Http Client.

bmargulies
can i use it on app engine ?
Bunny Rabbit
It's just a jar file. I don't see why not, but I'm never used it.
bmargulies