Rooster
Rooster is a Java wrapper for the Digg API. Although it hasn’t been fully tested yet, it does appear to be working 100%. It’s released under the MIT license.
Example Usage
Getting a list of stories
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /** * The first thing you need to do is create an instance of the * Rooster class. You will need to pass your application key as * a constructor parameter. * @link http://apidoc.digg.com/ApplicationKeys */ Rooster rooster = new Rooster("http://headzoo.com/rooster"); /** * From here you use the ListStories class to get story information * from Digg. You can create a new instance of ListStories and pass the * Rooster instance to it's constructor, or you can use the stories() * method in the Rooster class, which returns a new instance of * ListStories. * For the first example, lets just get a list of all stories on Digg. */ StoryList stories = null; try { stories = rooster.stories().fetchAll(); } catch (DiggRequestException ex) { System.err.println(ex.getMessage()); System.exit(1); } for(Story story: stories) { System.out.println("Title: " + story.getTitle()); System.out.println("Status: " + story.getStatus().toString()); System.out.println("User: " + story.getUser().getName()); System.out.println("Diggs: " + story.getDiggs()); System.out.println("Link: " + story.getLink()); System.out.println("Href: " + story.getHref()); System.out.println("Container: " + story.getContainer().getName()); System.out.println("Topic: " + story.getTopic()); System.out.println(story.getDescription()); System.out.println(); } |
The output will look something like this:
Title: Amare Stoudemire cries like a baby after Bowen smacks him Status: upcoming User: jukimol Diggs: 1 Link: http://www.youtube.com/watch?v=2gQYpdOjjQA Href: http://digg.com/people/Amare_Stoudemire_cries_like_a_baby_after_Bowen_smacks_him Container: Offbeat Topic: People Was it a dirty play or is Amare a big crybaby? Title: Ron Paul and Bill O'Reilly Duke It Out Status: upcoming User: RPliberty Diggs: 1 Link: http://www.youtube.com/watch?v=R7JPvbVsDdY&feature=related Href: http://digg.com/2008_us_elections/Ron_Paul_and_Bill_O_Reilly_Duke_It_Out_4 Container: World & Business Topic: US Elections 2008 Great flashback of truth vs neocon Title: Ad Populi Status: upcoming User: Scepticon Diggs: 1 Link: http://scepticon.wordpress.com/2008/04/10/ad-populi/ Href: http://digg.com/educational/Ad_Populi Container: Lifestyle Topic: Educational A brief look at the fallacy of ad populi and how it affects the decisions people make. Title: [BakitWhy.com] hi. my name is justin. i'm socially awkward Status: upcoming User: jerpoop Diggs: 1 Link: http://www.bakitwhy.com/2008/04/hi-my-name-is-justin-im-social.html Href: http://digg.com/comedy/BakitWhy_com_hi_my_name_is_justin_i_m_socially_awkward Container: Offbeat Topic: Comedy i guess since you are visiting my page, you have at least SOME interest on what i have to say. well, on here, i will post blogs and vlogs of anything i feel like writing/talking about at any given time, so keep visiting back! [bakitwhy.com]
There are more examples in the com.headzoo.net.services.digg.examples package. More detailed documentation is coming soon!





Recent Comments