Change comment:
There is no comment for this version
Summary
-
Objects (1 modified, 0 added, 0 removed)
Details
- XWiki.FAQClass[0]
-
- Answer
-
... ... @@ -4,9 +4,8 @@ 4 4 5 5 {code} 6 6 <% 7 - URL twitterURL; 8 8 try { 9 - timelineURL = new URL("http://twitter.com/statuses/public_timeline.xml"); 8 + URL timelineURL = new URL("http://twitter.com/statuses/public_timeline.xml"); 10 10 11 11 def connection = timelineURL.openConnection(); 12 12 def text = connection.content.text ... ... @@ -29,15 +29,16 @@ 29 29 30 30 {code} 31 31 <% 32 - updateURL = new URL("http://twitter.com/statuses/update.xml"); 31 + try { 32 + updateURL = new URL("http://twitter.com/statuses/update.xml"); 33 33 34 - 34 + def connection = updateURL.openConnection(); 35 35 36 - 36 + connection.setRequestProperty("Authorization", "Basic " + 37 37 (new sun.misc.BASE64Encoder().encode("username:password".getBytes()))); 38 38 39 - 40 - 39 + connection.setDoOutput(true); 40 + connection.setRequestMethod("POST"); 41 41 42 42 def osr = new OutputStreamWriter(connection.getOutputStream()); 43 43 osr.write("status="+"Here the status you want to update"); ... ... @@ -44,6 +44,12 @@ 44 44 osr.close(); 45 45 46 46 def responseText = connection.content.text 47 + 48 + //[...] 49 + 50 + } catch (Exception e) { 51 + print( e.message + "\n" ) 52 + } 47 47 %> 48 48 {code} 49 49