How to get share (view) count of current page URL from StumbleUpon (use jQuery.getJSON)?

265 Views Asked by At

I try to get share (view) count of URL from StumbleUpon on my site (I use this page in official API for understanding JSON response):

$.getJSON('http://www.stumbleupon.com/services/1.01/badge.getinfo?url=' + encodeURIComponent(location.href) + '&callback=?', function(response) {
  console.log(response.result.views);
});

Also I try this code:

$.getJSON('http://www.stumbleupon.com/services/1.01/badge.getinfo?url=' + encodeURIComponent(location.href) + '&callback=?', function(response) {
  var getResult = 'result';
  for (var getResult in response) {
    if (response.hasOwnProperty(getResult)) {
      var count = response.getResult.views;
      break;
    }
  }
  console.log(count);
});

But Google Chrome console always show me this error message:

badge.getinfo?url=http%3A%2F%2Fmysite.com%2F&callback=jQuery11120638845409732312_14430823…:1 
Uncaught SyntaxError: Unexpected token :

If I try this link http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://www.treehugger.com (for example) in browser, I get this response:

{
    "result": {
        "url": "http:\/\/www.treehugger.com\/",
        "in_index": true,
        "publicid": "1tin26",
        "views": 109703,
        "title": "TreeHugger",
        "thumbnail": "http:\/\/cdn.stumble-upon.com\/mthumb\/428\/925428.jpg",
        "thumbnail_b": "http:\/\/cdn.stumble-upon.com\/bthumb\/428\/925428.jpg",
        "submit_link": "http:\/\/www.www.stumbleupon.com\/submit?url=http:\/\/www.treehugger.com\/",
        "badge_link": "http:\/\/www.www.stumbleupon.com\/badge?url=http:\/\/www.treehugger.com\/",
        "info_link": "http:\/\/www.www.stumbleupon.com\/url\/www.treehugger.com\/"
    },
    "timestamp": 1289496144,
    "success": true
}

Any ideas? Help me please, if you can!

0

There are 0 best solutions below