Skip to content

Instantly share code, notes, and snippets.

@alcides
Created August 7, 2009 19:46
Show Gist options
  • Save alcides/164125 to your computer and use it in GitHub Desktop.
Save alcides/164125 to your computer and use it in GitHub Desktop.
import java.io._
import java.net.{URLConnection, URL}
import scala.xml._
val username = "alcides"
val password = "youwish"
val conn = new URL("http://twitter.com/statuses/friends_timeline.xml").openConnection
val encoding = Base64Converter.encode( username + ":" + password )
conn.setRequestProperty("Authorization", "Basic " + encoding)
def user(st:Node):String = ((st \ "user" last) \ "screen_name" last) text
def body(st:Node):String = (st \ "text" last) text
(XML.load(conn.getInputStream) \\ "status").map {
st => user(st) + " said: " + body(st)
}.foreach{
line => println(line)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment