So you've had some success using Digg.com as a venue to promote your content. You've managed to rack up a few posts with high Digg counts; maybe you've even had your day on the front page. You know that even moderately popular Digg postings get a lot of attention; so you start evaluating everything you write in terms of its "Diggability", for better or for worse.
Then you notice something: a lot of people are reading your content, and commenting on it; but most of them are doing so through your story widget on Digg.com, rather than domestically, on your website. Indeed, the more popular the article gets, the more it can feel like your site has gotten lost in the shuffle. It looks something like this:
You're happy to get any comments, of course, on Digg.com or elsewhere. But it sure would be nice if you could magically "export" that juicy Digg comment list back to the page which originated the article, so that Digg comments and domestic comments are displayed seamlessly together. One big, happy family: isn't that how it should be?

So today, I'd like to talk about how to leverage the Digg API to accomplish just that. First, let me state the Golden Rule of Digg.com Customization:
You can access virtually any aspect of Digg content by making a plain-vanilla HTTP request, and massaging and displaying the response to that request using PHP, ASP.NET, Javascript, or what ever technology you want.
The smart folks behind Digg.com have put together an extremely flexible API which allows you to filter and extract just about anything - users, comments, digg counts - by querying a particular HTTP endpoint. If the term "HTTP endpoint" isn't particularly meaningful to you - allow me to rephrase. You use the Digg API by making requests for particular URLs, and interpreting the data those requests return. The format of the URL is determined (and documented) by Digg, as is the format of the data you get back.
The upshot is that there's no single way to implement Digg comments on your site. There are about a hundred ways, each slightly different than the next.
When I say a "plain-vanilla" HTTP request, I mean something you could type into a browser window. Click the following link to see this in practice:
http://services.digg.com/stories/6200199/comments?appkey=http%3A%2F%2Fwww.codingthewheel.com
This is a real-world use of the Digg API. It says, "get me all the top-level Digg comments associated with Story #6200199, whatever that is."
(Every story on Digg is identified by a unique number, and 6200199 just happens to reference The Great Game, a post I published last week.)
Here's the data returned when the above URI is requested:
Even if you're not an XML afficionado, you can see that there are three comments here. If you look closely, you'll see that each comment has both a "user" and a "date" attribute, along with some other data. Now, if only you could get your hands on that data, in the context of your website or blog... you'd have everything you need to display integrated Digg comments.
You're not required to work with XML. You can instruct Digg.com to frame its responses in one of four formats:
You can easily tweak the response type by adding a "type" parameter to the request. Here's one that returns the exact data you saw above, but this time in a serialized PHP format:
http://services.digg.com/stories/6200199/comments?appkey=http%3A%2F%2Fwww.codingthewheel.com&type=php
Here's the response returned for the above request:
This is serialized PHP. While it may look like a lot of gibberish: it makes your life easier, and in practice you'll rarely, if ever, have to actually look at it. Instead, you'll deserialize it, and talk to a set of friendly objects.
Every request to Digg.com should include an "app key" or application key, which identifies the particular website or application making the request.
http://services.digg.com/stories/6200199/comments?appkey=http%3A%2F%2Fwww.codingthewheel.com
The application key is just the absolute URL of your website, suitably encoded (URL-encoded, to be specific). According to the Digg.com API documentation:
The value of the appkey argument is up to you, within the constraints described below. Digg does not issue or authenticate appkeys at this time. It is used only for statistical purposes.
You may not be able to keep your selected appkey secret. We can't think of any reason someone would want to sniff your appkey and use it for their own, but silly mischief is always a possibility.
The value of the appkey argument must be a valid absolute URI (see IETF RFC 2396) that identifies the application making the request. The URI might point to:
- 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.
Or you may use a URI that doesn't actually point to a document on the worldwide web, but uniquely identifies your application.
The value of the appkey argument must be URL encoded
So assuming your site is www.somesite.com, your application key would look like this:
appkey=http%3A%2F%2Fwww.somesite.com
Make sure to append that to the end of each and every request you make to the Digg API, and otherwise you can forget about it.
One of the problems I had early on was figuring out how to retrieve the story ID for a given arbitrary story, given the original URL of the page on which the story was published.
In other words, given some hypothetical URL...
http://www.codingthewheel.com/archives/the-great-game
...how do you retrieve the Digg Story ID for this URL? (assuming it's been submitted to Digg in the first place)
Well, you can always do it manually, but it makes for a lot of busy-work:
Not to mention: what happens when someone else submits one of your stories to Digg, without you knowing about it?
So what we want is a way to grab this information on the fly, for any arbitrary page on our site. As luck would have it, the Digg API allows you to do this through the link query parameter.
http://services.digg.com/stories?link=http%3A%2F%2Fwww.codingthewheel.com%2Farchives%2Fthe-great-game&appkey=http%3A%2F%2Fwww.codingthewheel.com
Go ahead and click the link if you want. You should see something like this:
The XML response consists of a stories collection containing zero or more story elements. There can be multiple Digg story IDs associated with a particular URL, for example, in the case of duplicate submissions, or if a particular URL happens to contain two or more stories. But generally and on average, you'll find that there's a one-to-one correlation between the original URL of the article, and the Digg Story ID corresponding to that article.
I've bolded and underlined the relevant piece of data: the "id" attribute for the story. There you see it: 6200199. Once you have this piece of information, you can then make various other requests to Digg - such as retrieving a list of comments - which require that you have a Story ID.
So now that you know how to retrieve the numeric Story ID for a given page on your site, you can extract the list of Digg comments associated with the story. You've already seen (above) the format of the request you'll need to make:
http://services.digg.com/stories/6200199/comments?appkey=http%3A%2F%2Fwww.codingthewheel.com
Simple replace the story ID with the appropriate ID for your own Digg submissions.
Actually, the above request will only return the top-level comments for a given story. If you want to drill down into comments-on-comments, or comments-on-comments-on-comments, you'll need to make a separate request. This is beyond the scope of this article, but if you can get top-level comments working, you shouldn't have too much trouble drilling down and exposing sub-comments as well.
Digg uses the Unix "epoch" format for date times. Under this format a date/time is expressed as:
the number of seconds elapsed since midnight Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds
So decoding it is just a matter of calculation. Using C#, it would look something like this: (there are many, many code samples showing how to work with Unix datetime formats, in all languages - a good Google search will get you started)
So you understand how to make a request to the Digg API - roughly. You understand that you can decode the data returned by that request - roughly. But what does it all look like when you put it together?
Here's a sample, extremely rough, non-refactored, naive, basic implementation using ASP.NET. It does the following:
You could place this code in a Page.Load event handler, for example. There are better approaches, such as placing your Digg comment extraction logic in an HTTP Handler, referenced by a piece of Javascript/AJAX on the client side, but that's beyond the scope of this article.
The code is fairly straightforward. We're making two separate HTTP requests to service.digg.com. The first request retrieves the story ID, the second request retrieves the list of comments associated with that story.
After that, it's up to you to figure out how to integrate this data with the rest of your comments, your particular CMS or blogging platform, etc. But you've seen the broad strokes.
This article barely scratches the surface of what's possible using the Digg API. It would be possible to write a book on this subject, but hopefully this article has given you enough to get started.
If you'd like to check out the (very simple, but demonstrative) way I'm using integrated Digg comments here on Coding the Wheel, check out the comments for my Great Game post. Or assuming this post itself gets Digged, you might be able to see some comments below.
Other than that, thanks for reading (as always), and good luck.
27 comment(s)
Cool! I'll be trying this out shortly. Thanks for the information. -John
John T. Baker on Wednesday, April 30, 2008digg sucks i hate digg.com with a passion all you looooosers need to learn some truth and come on over to reddit.com where the big boys play...
obi wan kerFLOBI on Wednesday, April 30, 2008plsntvll: Thanks for the vote of confidence. I don't have a way yet to make these comments go back to Digg.com, otherwise you'd probably be able to read this. ;-)
John: You're most welcome, and good luck.
obi wan kerFLOBI: May the Force be with you.
James Devlin on Wednesday, April 30, 2008Great article, James! Another way to get information on a story is by using the "clean title", from the URL on Digg:
...becomes:
You can also get all stories from your domain like this: http://services.digg.com/stories?domain=codingthewheel.com&appkey=http%3A%2F%2Fwww.codingthewheel.com
Michal Migurski on Wednesday, April 30, 2008Some borked HTML crept into my comment up there, all I pasted was some raw URLs.
Michal Migurski on Wednesday, April 30, 2008Michal: First, thanks for the comment. Indeed, I looked into clean URLs, but I couldn't figure how to guarantee that, for a given aribitrary post title, I could reproduce the clean Digg URL for that post 100% of the time. For example, I might have a very long post title which I need to truncate on Digg. Or someone else might submit the story to Digg, and use a slightly different title.
So, since I don't want to necessarily have to store additional post metadata in my DB to describe, for example, the clean URL, or the story ID, I went with the [b]link[/b] approach, as one thing that both Digg and the originating site are guaranteed to have in common is the absolute URL of the post.
But the clean title approach would work in 95% of cases, and it does seem simpler than doing a story?link followed by a story/storyID or stories/storyID. So, something to consider.
Also, rather than endlessly hit the Digg API requesting story IDs, I'm now working to cache the story ID so it only needs to be retrieved once. Which is exactly the metadata approach I said I didn't want to use above, the only difference is, I don't have to manually retrieve or set anything.
And sorry about the borked HTML! having some growing pains. Should be fixed shortly.
James Devlin on Wednesday, April 30, 2008Interesting post- new twist- I see you are still working out the 'kinks', but looking pretty good. what i want now to know is: any way for to comment replies made on CTW back onto Digg? 2-way?
Phillip on Thursday, May 01, 2008One thing I am not sure about is how to inject the DIGG comments into my existing comments list for that post. I could implement an extension that retrieves during the page load but wouldn't that happen everytime someone loaded the blog entry? Wouldn't I want to somehow evaluate what comments have already been scraped off the DIGG site and then append any new comments to my list of comments?
Suggestions?
Chris on Thursday, May 01, 2008Chris: Ideally, import Digg comments and store them in your local DB, such that you only have to query Digg for new stuff. In that case your Post.Comments collection should already contain the native Digg comments.
If you don't want to store Digg comments in your DB, you can take the comment collection (Post.Comments, for BlogEngine.NET), shallow copy it, added the Digg comment collection to it, then sorted the entire collection. Comments happens to support IComparable so the collection gets ordered by date and you get a merged list of comments.
That may not be the best way, but that's what I initially tried, and it works passably well. And assuming you're doing some caching that code doesn't have to get run too often.
James Devlin on Saturday, May 03, 2008nice article. keep post like this...
Fendi replica watches on Tuesday, July 20, 2010I loved this post so much. This was great. Keep it up!
Tudor replica watches on Saturday, July 24, 2010PerformingGraham for sale that will create a one-wayswiss watches backlink to your website whichMaurice Lacroix watches is a good point to have. It is Patek Philippe watchesa time-consuming Tag Heuer for saleprocess even though it produces good outcomes U-boat for saleand works. You can also swiss watchespost comments on blogs alongMaurice Lacroix watches together with your link, but make sureGraham watches these blogs are do-follow, which dolce & gabbana handbagsindicates the link that youreplica coach handbags simply post will probably be replica handbagscounted by the search engines jimmy choo replicaas a backlink.There are many thingsversace replica handbags that contribute to online businessjuicy couture replica failure, and the lack of good action thomas wyldeis surely one of the deadliest business-killersdolce gabbana handbags on the net. Take action like by no means chloe handbags replicaprior to, and don’t get struck by analysis paralysisburberry replica. Your achievement lies in your rapid actionchanel replica and how well you apply numerous strategies.
replica watches on Saturday, July 24, 2010nike air jordan 2010 nike air jordan 5 nike air jordan 3 nike air jordan 11 cheap nike air jordan 2 nike air jordan 1 nike air jordan shoes discount nike air jordan shoes nike air jordan 6 wholesale nike air jordan 1 discount nike air jordan 6 nike air jordan 7 nike air jordan 8 top quality nike air jordan shoes 23 nike air jordan 21 nike air jordan 22 nike air jordan 6 rings cheap nike air jordan 22 nike air lebron james shoes nike air lebron james shoes nike air jordan 2010 nike air joredan lebron james nike air jordan 2009 discount nike air jordan 2009 nike lebron james wholesale nike air jordan 2010 cheap nike air jordan 2009 discount nike air jordan 19 cheap nike air jordan 3 discount nike air jordan 18 brand nike air jordan 12 wholesale nike air jordan 2 nike air jordan 13 nike air jordan 14 nike air jordan 6 rings discount jordan shoes7 discount jordan shoes1 jordan shoes2010 jordan shoes 6 rings cheap jordan shoes2 discountjordan shoes3 discount jordan shoes4 jordan shoes uk23 jordan shoes classic bw22 cheap jordan shoes 21 ltd discount jordan shoes20 discountjordan shoes19 jordan shoes 18 uk nike air jordan shoes 17 cheap nike air jordan shoes 16 discount air jordan shoes 15 discount air jordan shoes 14 nike air jordan shoes 3 uk nike air jordan shoes 13 cheap nike air jordan shoes 11 discount air jordan shoes 6 discount jordan shoes 10 nike air jordan shoes 8 nike air jordan shoes 7 cheap louis vuitton bags cheap kobe bryant shoes cheap lebron james shoes .
cheapjordan on Saturday, July 24, 2010I will keep visiting this blog very often. Blu ray ripper /
ipad converter on Sunday, July 25, 2010Welcome to high quality youth nfl jerseys store
youth nfl jerseys on Sunday, July 25, 2010cheapest youth nfl jerseys wholesaler including NBA/MLB/NHL/Football jerseys,all cheap jerseys are high quality,waiting for u visiting.
Welcome to high quality youth nfl jerseys store
youth nfl jerseys on Sunday, July 25, 2010cheapest youth nfl jerseys wholesaler including NBA/MLB/NHL/Football jerseys,all cheap jerseys are high quality,waiting for u visiting.
It is a good timberland 6 inch boots thing that the God Who made us is not impatient with people like me with my timberland shoe company orchid. He lovingly thinks about us all the time timberland boots and he even temporarily gave up His heavenly home and his timberland traditional handsewn hold on diety to die for the sins of timberland mens custom world nearly 2,000 years ago. His death back then covered the sins of every cheap timberland boots person who will ever live. He then rose to life after three mens timberland chukka days and ever since has wanted us to accept His gracious act by loving Him and also those around us. When we do this, we will see people in a totally different timberland womens premium boots light — one that redefines what it means to be ugly or different or weird or strange. Instead, we see people with ugly timberland shoes store problems in whom God is working so they can bloom beautifully — just like I now see in my orchids whether they are “lumps” or blossoms! On a certain timberland work shoes day at a certain hour, we will pull into the station. Bands will be playing and flags waving. Once we get there, so many wonderful dreams will come true and the pieces of our timberland wheat shoes lives will fit together like a completed jigsaw puzzle. How restlessly we pace the aisles, *ing the minutes for timberland for you loitering --waiting, waiting, waiting for the station.
discount timberland boots on Wednesday, July 28, 2010Many people think that owning a Louis vuitton online is owning one of the best handbags in the world. It is true that it is one if not the
Check out Sofias Replicas selection of fake lv outlet. Sofia's Replica for all you fake handbag needs.
Our Louis vuitton handbags, replica bags are hard to beat Louis vuitton of exporting the Fake handbags, we determined to bring our customers the best replicas
louisvuitton4 on Thursday, July 29, 2010mmediate action after the dream Christian Louboutin Shoes and charming Pandora Jewelry,healthy life quality, you may need to Zumba Fitness DVD or P90X or Insanity Workout DVD video tutorial, doing exercise of his presence engaging.Christian Louboutin Knockoffs,Christian Louboutin Wedding Shoes, Christian Louboutin Boots,Christian Louboutin Sandals,Christian Louboutin Wedges,Christian Louboutin Platform,P90X DVD,DVD Sales,Vibram Five Fingers,Herve Leger,Cheap Christian Louboutin,Alexander Wang Dress,Alexander Wang Shoes,Alexander Mcqueen Shoes,Giuseppe Zanotti Shoes,ED Hardy Shoes,Jimmy Choo Shoes,Chanel Shoes,YSL Shoes,Manolo Blahnik Shoes,Vivienne Westwood Shoes,Tory Burch Shoes,Louis Vuitton Shoes,Miu Miu Shoes,Salvatore Ferragamo Shoes,Marc Jacobs Shoes,Christian Dior Shoes,Herve Leger,Sergio Rossi Shoes,Lanvin Shoes,Coach Shoes,Prada Shoes,Gucci Shoes,Moncler Jackets,MBT Shoes
christian louboutin on Thursday, July 29, 2010Wholesale NFL Jerseys
Cheap NFL Jerseys
NFL Jerseys
NFL Football Jerseys
Women NFL Jerseys
Kid NFL Jerseys
Super Bowl Jerseys
Super Bowl NFL Jerseys
Throwback Jerseys
Throwback NFL Jerseys
Cheap Throwback Jerseys
Wholesale Throwback Jerseys
Cheap Super Bowl Jerseys
Wholesale Super Bowl Jerseys
youth nfl jerseys wholesale
youth nfl jerseys cheap
nfl youth jerseys
Baltimore Ravens Jerseys
Chicago Bears Jerseys
Cincinnati Bengals Jerseys
Denver Broncos Jerseys
Dallas Cowboys Jerseys
Green Bay Packers Jerseys
Indianapolis Colts Jerseys
Minnesota Vikings Jerseys
New England Patriots Jerseys
New Orleans Saints Jerseys
New York Jets Jerseys
Arizona Cardinals Jerseys
Buffalo Bills Jerseys
Atlanta Falcons Jerseys
Carolina Panthers Jerseys
Cleveland Browns Jerseys
Houston Texans Jerseys
Detroit Lions Jerseys
Jacksonville Jaguars Jerseys
Kansas City Chiefs Jerseys
Miami Dolphins Jerseys
New York Giants Jerseys
Philadelphia Eagles Jerseys
San Francisco 49ers Jerseys
Oakland Raiders Jerseys
Seattle Seahawks Jerseys
Pittsburgh Steelers Jerseys
St Louis Rams Jerseys
San Diego Chargers Jerseys
Tampa Bay Buccaneers Jerseys
Tennessee Titans Jerseys
Washington Redskins Jerseys
Ray Lewis Jerseys
Ed Reed Jerseys
Joe Flacco Jerseys
Terrell Suggs Jerseys
Dick Butkus Jerseys
Greg Olsen Jerseys
Matt Forte Jerseys
Devin Hester Jerseys
Walter Payton Jerseys
Brian Urlacher Jerseys
Lance Briggs Jerseys
Jay Cutler Jerseys
Carson Palmer Jerseys
Rey Maualuga Jerseys
Chad Johnson Jerseys
Demarcus Ware Jerseys
Jason Witten Jerseys
Terrell Owens Jerseys
Felix Jones Jerseys
Marion Barber Navy Jerseys
Marion Barber Jerseys
Emmitt Smith Jerseys
Miles Austin Jerseys
Roger Staubach Jerseys
Troy Aikman Jerseys
Tony Romo Jerseys
Eddie Royal Jerseys
Brandon Marshall Jerseys
Aaron Rodgers Jerseys
A.J. Hawk Jerseys
Donald Driver Jerseys
Greg Jennings Jerseys
Peyton Manning Jerseys
Dallas Clark Jerseys
Robert Mathis Jerseys
Marvin Harrison Jerseys
Drew Brees Jerseys
Marques Colston Jerseys
Pierre Thomas Jerseys
Reggie Bush Jerseys
Jeremy Shockey Jerseys
Tarvaris Jackson Jerseys
Adrian Peterson Jerseys
Jared Allen Jerseys
Mark Sanchez Jerseys
Thomas Jones Jerseys
Leon Washington Jerseys
Brett Favre Jerseys
buynflshop on Thursday, July 29, 2010YouTube streaming video - Louis vuitton Journeys: the greatest game - For the world cup 2010 lv outlet launch a special ad
campaign with
Price:$200. Louis vuitton Tambour elegants lv Here you can find such world top brands as Omega watches, Rolex watches,
We are the best site with superb Customer service and Best lv handbag. Most Fake Cheap Louis vuitton Watches Items In Lowest Price
Swiss Louis vuitton ETA replica · Swiss Montblanc ETA replica .... Our store provides the best Swiss lv bag in the UK.
We are proud to announce that we showcase the best in the designer luggage with the lv bags. With us, you have access to a wide range
of ...
louis vuitton on Thursday, July 29, 2010Coach outlet coach bags gucci outlet Coach High Heels Coach Heels coach sunglasses New Coach Handbags Coach Baby Bags Coach Claire Bags Coach Leather Handags Coach Patchwork Purse Gucci Leather Wallets Gucci Sunglasses Gucci Shoes Gucci Leather Shoes Gucci Men Slippers Gucci Sandals
CoachHeels on Friday, July 30, 2010Gucci Hats
essay essay writing essay writing service essay writing service uk
jane on Friday, July 30, 2010Pool Temperature Madera Jobs Madera Pest Control Madera Dentist Merced Dentist Visalia Dentist Modesto Dentist Fresno Limousine Fresno Granite briefcases leather leather briefcases prospect solution | prospect solutions | prospectsolution | prospectsolutions | prospectsolution.com prospect solution | prospect solutions | prospectsolution | prospectsolutions | prospectsolution.com prospect solution | prospect solutions | prospectsolution | prospectsolutions | prospectsolution.com
carmi on Friday, July 30, 2010Go and catch your louis vuitton handbags from here, we will do our best to serve for you; If you're looking for Air Jordan shoes, you may have realized it is a difficult task to find them. We strive to provide you with information on online shoe stores that carry authentic Nike Air jordan shoes; nike shoes unlike a lot of regular running shoes, its flexibility provides a world of comfort on the run or while walking around, buying it from our mall and you will benefit a lot; When it comes to retro, cool designs Adidas does a great job with every sneaker release. At Sole Heaven, we have a really impressive arsenal of adidas shoes to do just the job; It is time for the Gucci fans to make some changes, please treat yourself with a different classic gucci handbags here, that will be a great surprise; Where can you find ugg boots for sale? Learn how smart buyers look for uggs for sale. Find the best online offers for directions.
nike shoes on Friday, July 30, 2010Want to get Ed hardy at home? No hesitation, get them at with big discount. We are promise you that all the ed hardy clothing are good in qualities. Meanwhile, buying ed hardy clothing online, that’s never a bad idea. By the way, whenever and wherever you need us, we will be there for you. Ed Hardy T-Shirts are waiting for you now, welcome you!
ed hardy on Friday, July 30, 2010Very useful article, thanks for the info
SEO Packages on Friday, July 30, 2010