Tuesday, July 24, 2007

New Digg Widgets

When I was browsing Digg today I noticed a new link near the top 10 box on the right side, which mentioned widgets. If you check out the widget link, you might notice that Digg has made it a little easier to add their content to any web page, via widgets. You can check out the blog post about it here.

There are still a few issues however, which luckily makes my blog scheme still relevant for Digg. Through the options in the widget, it still not possible to replicate the widget that is on the front page of Digg -- which displays the top 10 Digg submissions within the past 12 hours. Yesterday, I explained how to use the Digg API to access this information in xml format, and soon I will release the code as well as an explanation of how to organize this data and format it for publishing.

You have to wonder though, if Digg is going to make this widget available to the public, then why don't they include the option to publish the widget that is shown on the front page? It is obviously the most popular, as well as the most viewed. Plus, if it is possible to grab the widget anyway through a bit of work with the API, then wouldn't it just be smart of them to include the option within their own widget?

I don't mind much myself, because I have the ability to make a hacked up form of the widget available to the public -- it just seems that Digg would benefit from making it available themselves.

Monday, July 23, 2007

Top 10 Diggs Over Past 12 Hours

The first step towards grabbing the top 10 diggs over the past 12 hours is working with the Digg API. Digg has set up their API to make the information on Digg.com easily available to everyone. If you take a look at the "List Stories" link on the far right, you will see some documentation on how to use the api to grab a list of stories -- which is exactly what we want.
Since we know that we want a list of stories for our end goal, the url that we are going to use for the api is going to start like this:

  • http://services.digg.com/stories
Next, we tag on a /popular to make sure that we are grabbing stories that have popular status. From here we can set a couple arguments to make the data returned a little more specific. These arguments will be count, min_promote_date, and we will also need to set appkey. Heres how it is going to look:
  • count=100
  • min_promote_date=[current time - 12 hours]
  • appkey = [the url making the request, or something similar]
If you are just looking for the url, here is the end result:



http://services.digg.com/stories/popular?count=100&min_promote_
date=1185219546&appkey=http://red-top10.blogspot.com




Here is the explanation: We set count to 100 because we want the most results possible, and Digg sets a limit of 100 on the number of stories returned. In case you are curious, the default for count is 10 if you decide not to specify a number for it. The min_promote_date is required to be in the number of seconds since the unix epoch time format. The time I just put into that link was at
Monday, July 23rd 2007, 8:12:27 (GMT). This is because at the moment I wrote the link, Monday, July 23rd 2007, 8:12:27 (GMT) was exactly 12 hours ago. Last, appkey always needs to be set in order to use the api, and it needs to be set to the url making the request or a few other options. Here is how Digg describes what it needs to be:
  • The application itself, if it's a web application.
  • A web page describing the application.
  • A web page offering the application for download.
  • The author's web site.
From here, we have the data we need in xml format. However, we still have a little work to do. We need to sort the results by number of diggs, and then output the stories in a neat little format. Check back tomorrow for that stage of the digg top 10 list.

Beginning of The Top 10

I have noticed over my time on the web that top 10 lists are quite popular. Through my knowledge of web development, I would like to make top 10 lists more easily accessible to the world. I am even going to explain how to do it. If you stick around and read this blog, you will find coding advice, regex examples, and much more. If you aren't interested in that, then just enjoy the collection of lists that you will be able to view in one place.

The first top 10 list to be done is going to be from Digg. I am going to set up a script that will grab the top 10 most popular posts within the last 12 hours, and it will constantly update itself. If you haven't noticed yet, this will be the same list that is shown on the front page of Digg, on the right sidebar. Check back tomorrow for some more news.