Get the number of popular digg posts for a URL

Sometimes, for instance when you're building a domain-info tool, you want to know the number of posts on that site that have made it to the Digg frontpage. After playing a bit, I came up with this pretty easy code:

[code language="php"]
function FrontpageDiggs($url) {
$result['source'] = "http://digg.com/rss_search?search=".$url."&area=promoted&type=url&section=all";
$output = file_get_contents($result['source']);
preg_match_all("/.*().*/",$output,$matches);
$result['result'] = count($matches[1]);
return $result;
}
[/code]

Now if you echo $result['result'], you'll get the number of posts for $url that made the frontpage.

Related posts

  1. MSN launches Dutch Digg clone, but forgets spam prevention
  2. Getting Google's last visit date from the Google API
  3. Easily display your last Tweet
  4. Digg submit buttons: a good idea?
  5. Implementing a sitewide search function

Enjoyed this article?

Join 4714 subscribers and subscribe by daily or weekly emails or with RSS to receive more tips, tricks and ideas on improving your website!

2 Responses to “Get the number of popular digg posts for a URL”

Hosting by:
Hosted by MediaTemple Grid Services