开发者

Twitter basic authorisation not working?

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

HttpURLConnection conn = (HttpURLConnection) url.o开发者_Python百科penConnection();
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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜