Wednesday, January 14, 2009

Google data twitters

I long had a hunch that Google Data API is not the only Atom-based API out there, but never had the time to investigate. Now I just had a look at twitter (although I'm not a user -- yet), and it turns out the XML combinators I wrote some time ago for Google Data work out-of-the box! I was so happy to notice, I had to twitter blog about it.

GData-Scala-client is a library for using Google services programmatically. The core of this library is a collection of combinators for XML serialization, together with picklers for atom and other common data. Since Twitter offers an atom-based feed API, I decided to give it a shot. I fired a Scala interpreter:

scala> import

scala> val service = new Service("acme-twitter", "tw") {}
service: = $anon$1@dfee1

Make sure you start scala including the path to your downloaded gdata-scala-client jar. The Service class we created takes care of sending simple queries over HTTP and applying a pickler on the returned data. The two parameters are the application and the service name, but they have no meaning outside Google's realm, so we can be creative. Now let's make a simple query:

scala> import data._
import data._

cala> val atomFeed = new StdAtomFeed
atomFeed: =

scala> val f = service.query("", atomFeed.feedPickler)
res1: atomFeed.Feed =
Title: (None,Twitter public timeline)
Updated: 2009-01-14T21:04:11.000Z
Entries: Entry:
Authors: (Robert Basic,Some(,None)
Id: Some(,2007:
Title: (None,robertbasic: @bojanpejic thanks mate :) you'll see it tomorrow in action ;))

Surprise! It really worked! (at least, that was my reaction). Let's see what we had to do: create an instance of StdAtomFeed, which is a class defining the standard contents of an atom feed, together with the right pickler (serialization objects). Next, we issued a query, passing the URL and the pickler to deserialize the response.

We can further play with the Atom feed, inspecting its entries, or learning more about its contents:

scala> f.updated
res10: = 2009-01-14T21:04:11.000Z

scala> f.entries.filter (_.authors.exists("K") ))
res17: List[atomFeed.Entry] =
Authors: (Katie,None,None)
Id: Some(,2007:
Title: (None,myheartradio: @E_Steve Chapter Six...I'm not too far into it yet.)
Updated: 2009-01-14T21:04:11.000Z)

That's about how far I got. Authentication does not yet work, as Google Services use a different protocol. You can find out more about what's available here, but overall it's good news and I hope others will find this library useful as well.


Nifty option Tips said...
This comment has been removed by the author.
Nifty option Tips said...

I read your post . it was amazing.Your thought process is wonderful.
The way you tell about things is awesome. They are inspiring and helpful.Thanks for sharing your information and stories.
nifty option tips

Robert Glenn said...

This post is just fantastic, this topic of quite good
Watch Dogs Jacket

Daniyal Khatri said...

i read a lot of stuff and i found that the way of writing to clearifing that exactly want to say was very good so i am impressed and ilike to come again in future..
best backlink gig fiverr alternatives

rooseveltkuhn said...

After a long time back, i got a detailed article about "Google data twitters". its a need topic for me and i got a detailed article from here. anyway, thank you so much for the great share

Cheap essay writing service

Dennis Davis said...

Well, its obvious that google is saving your tweet, it's amazing how much data google keep in their servers. Read more about it Keep it up!

Anakin Swan said...

I enjoyed over read your blog post. Your blog have nice information, I got good ideas from this amazing blog. I am always searching like this type blog post. I hope I will see again..
animal jam| cool games| cool math games| 8 ball pool| sudoku| yoob| stickman games| unblocked games | shooting games| friv4school|
happy wheels| fighting games| happy wheels | happy wheels