![]() |
Languages »
C# »
General
Intermediate
digg API.NET - C# Implementation of digg Web ServicesBy thund3rstruckA C# Library Interface For the Digg.com API |
C#2.0, Windows, .NET2.0VS2005, Dev
|
||||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
Download DiggAPI.zip - 30.6 KB

Aside from being entertaining, digg.com provides a wealth of priceless information regarding comtemporary culture, science, sports, business, lifestyle, and technology. In the past, aggregating this data meant one had to use screen-scraping techniques with a mountain of Regular Expressions. Thankfully, digg has now provided users with a rich API for getting at it's data. My goal was to abstract the interface into a .NET object oriented library that can be imported into any project. It's still lacking a few features I'd like to add but it's certainly useable.
However, since I had already come this far with the digg API I set about completely the portions I had begun and this article outlines that effort.
The full documentation is available from the digg.com api site.
http://services.digg.com/story/popular?appkey=http://www.codeproject.com
http://services.digg.com/stories/popular?count=25&appkey=http://www.codeproject.com
/stories - All stories.
/stories/popular - Popular stories.
/stories/upcoming - Upcoming stories.
/stories/container/{container name} - All stories from a given container.
/stories/container/{container name}/popular Popular stories from a given container.
/stories/container/{container name}/upcoming - All stories from a given topic.
/stories/topic/{topic name}/popular - Most Popular stories in a topic
/stories/topic/{topic name}/upcoming - Upcoming stories from a given topic.
/story/{story id} - Identified story.
/stories/{comma-separated list of story ids} - A list of stories with the given ids.
/user/{user name}/submissions - Stories submitted by given user.
/topics - Get a list of all topics.
/users - All users.
/user/{user name} - Named user.
/user/{user name}/friends - Named user's friends.
/user/{user name}/activity - All digg and comment activity for a given user.
/user/{user name}/activity/diggs - All digg activity for a given user.
/user/{user name}/activity/comments - All comment activity for a given user.
/story/{story id}/activity - All digg and comment activity for a given story.
/story/{story id}/activity/diggs - All digg activity for a given story..
/story/{story id}/activity/comments - All comment activity for a given story.
//In the references add
using Baileysoft.Rss.DiggAPI;
StoryCollection articles = StoryCollection(ArticleType.byUserDiggs, "thund3rstruck");
foreach (Story article in articles)
Console.WriteLine(article.Description);

using Baileysoft.Rss.DiggAPI
Globals.Count = "3"; //max 99
Globals.AppKey = "http://www.codeproject.com"; //the referring site (your site)
Globals.Count = "25";
Globals.AppKey = "http://www.codeproject.com";
StoryCollection articles = new StoryCollection(ArticleType.popular);
foreach (Story article in articles)
Console.WriteLine(article.Title);
Globals.Count = "25";
Globals.AppKey = "http://www.codeproject.com";
StoryCollection articles = new StoryCollection(ArticleType.upcoming);
foreach (Story article in articles)
Console.WriteLine(article.Title);
Globals.Count = "25";
Globals.AppKey = "http://www.codeproject.com";
StoryCollection articles = new StoryCollection(ArticleType.topic, "apple"); //must be a valid topic
foreach (Story article in articles)
Console.WriteLine(article.Title);
Globals.Count = "25";
Globals.AppKey = "http://www.codeproject.com";
StoryCollection articles = new StoryCollection(ArticleType.topicUpcoming, "apple"); //must be a valid topic
foreach (Story article in articles)
Console.WriteLine(article.Title);
Globals.Count = "25";
Globals.AppKey = "http://www.codeproject.com";
StoryCollection articles = new StoryCollection(ArticleType.byUserSubmissions, "thund3rstruck");
foreach (Story article in articles)
Console.WriteLine(article.Title);
Globals.Count = "25";
Globals.AppKey = "http://www.codeproject.com";
StoryCollection articles = new StoryCollection(ArticleType.byUserDiggs, "thund3rstruck");
foreach (Story article in articles)
Console.WriteLine(article.Title);
Globals.Count = "25";
Globals.AppKey = "http://www.codeproject.com";
StoryCollection articles = new StoryCollection(ArticleType.byId, "2572048");
foreach (Story article in articles)
Console.WriteLine(article.Title);
Globals.AppKey = "http://www.codeproject.com";
TopicsCollection topics = new TopicsCollection();
foreach (string topic in topics)
Console.WriteLine(topic);
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 5 Oct 2007 Editor: |
Copyright 2007 by thund3rstruck Everything else Copyright © CodeProject, 1999-2010 Web18 | Advertise on the Code Project |