Subscribe to RSS feed

splitbrain.org - electronic brain surgery since 2001

Determine StumbleUpon Rankings

StumbleUpon is a popular social bookmarking service with a strong focus on discovering new pages which match your interest. It can be a great traffic source and gained a lot of interest by website owners including me.

When one of your pages is “stumbled” you might wonder how popular it is within the service. But unlike Digg, StumbleUpon does not publish the numbers of “thumbs up”.

StumbleUpon Search Enhancements StumbleUpon recently(?) added a “search result enhancement” feature to their toolbar. It adds StumbleUpon “star ratings” to Google results (See screenshot). This got me interested and I had a closer look at their extension…

To make a long story short: there is a special URL which will accept a list of URLs and returns some ranking data. No absolute numbers, but a general rating.

I quickly hacked the following PHP code to send custom queries to StumbleUpon:

function stumblecounts($url){
    $userid    = '12345';
    $authtoken = 'put your auth code here';
 
    $fetch = 'http://www.stumbleupon.com/links.php?username='.$userid.
             '&password='.$authtoken.'&u='.rawurlencode($url);
    $resp = file_get_contents($fetch);
 
    if(trim($resp) == '') return false;            // URL wasn't stumbled yet
    if(preg_match('/ERROR/i',$resp)) return $resp; // some error occured
 
    // parse answer in array
    $data = explode("\t",$resp);
    $info['comments'] = $data[0];
    $info['thumbed']  = $data[1];
    $info['score']    = $data[2];
    $info['topic']    = $data[3];
 
    return $info;
}

The function above accepts any URL as parameter and will return an associative array with the following data:

  • comment rating from 0 (low) to 4 (high)
  • thumbed – I have no idea what it does seems to be always 0
  • score rating from 0 (low) to 4 (high)
  • topic ID

The topic ID can be looked up in a CSV file if you need it. On error a string with the error message is returned and if you submit an URL which wasn't stumbled yet a false will be returned.

To make it work you will need to set the two variables at top of the function. It's your StumbleUpon internal UserID and an authtoken (which corresponds to your password). To find those values in Firefox type about:config in your address bar and put token in the filter box. It should result in something like this:

Finding the StumbleUpon AuthToken

There you have it. A simple way to check the popularity of a page in StumbleUpon ;-)

Tags:
stumbleupon,
php,
api
Similar posts:
Posted on Thursday, August the 30th 2007 (2 years ago).

Comments?

1
Thumbed, would that mean if you have gave the page a thumbs up? As when you have liked the page you get a blue thumb next to it, check it out anyways
2007-09-01 13:55:15
2
John, that's what I thought, too. But in my tests it always returned 0 even for pages I "thumbed up". My guess is, StumbleUpon intended to use this as we both think, but then removed it because it wouldn't be easily cacheable as each request would be user dependent.
2007-09-01 14:11:31
3
I tried this out, but I don't think its exactly like you said. I tried a page I know I have on stumble, this request returns [comments] => 3 however I can count 20 comments actually on stumble review page for the website. :S
2007-09-01 17:40:47
jb2386
4
Ah, n/m my comment. I misread what the comment value was.
2007-09-01 17:42:08
jb2386
5
Pretty nice trick!
2007-09-01 17:44:03
6
Sorry to flood your comments, but I seem to be getting the 'thumbed' value as you assumed it should work. If i thumb up a page, I get a value of 1, if I undo it, or thumb down I get 0.
2007-09-01 17:45:40
jb2386
7
So you have found out the popularity of a website in SU. Now what are you gonna do with it?
2007-09-01 19:12:39
Mats
8
@jb2386, really? Hmm maybe it was some caching issue that it didn't work for me. Great that it works for you.

@Mats, I don't know, yet :-). Maybe I'll display some of the info in the "Stumble it" link below the post, like I do for Digg. This wasn't easily possible before, because Stumbleupon doesn't have an API.
2007-09-01 20:18:52
9
That's awesome. I was wondering if there is a way to see how many pages under a certain domain have been "stumbled". Do you know?
2007-09-07 11:27:40
10
Well if you have a list of pages at the domain, you could use the described method to check them all. A list could be retrieved from a Google sitemap or by querying Google or Yahoo search through their APIs.

Hmm... AFAIK the SU toolbar also has a button to restrict stumbling to a certain domain - maybe this could be used to fetch a list of stumbled pages directly from StumbleUpon...
2007-09-07 13:01:01
11
Any ideas how to generate the authtoken from a users plaintext password? md5, sha1 doen't generate the right has ... that's if it is a hash!
2008-05-07 02:21:05
mike
12
Does anyone know if this still works? Whenever I try it I'm getting 'ERROR BAD_AUTH' I may be doing it wrong though...
2009-01-20 15:15:02
13
No, StumbleUpon seems to have changed something. Someone needs to figure out what they are doing now.
2009-01-20 15:18:09
14
Thanks for the quick reply Andi. I've been having a look at this and it looks like they've changed to use POST. I've made some changes to your function and it seems to work...

http://blog.johnlawrence.net/2 … -rankings/
2009-01-21 01:35:15
15
nice approach! I used the RSS feed for the urls and counted the comments in there, maybe this can be a nice addition.

http://wordpress.org/extend/pl … ss-plugin/
2009-11-21 21:27:39
CAPTCHA

No HTML allowed. URLs will be linked with nofollow attribute. Whitespace is preserved.