Answer the question
In order to leave comments, you need to log in
How to get the view count for the current URL from StumbleUpon (using jQuery.getJSON)?
Greetings!
I've been looking for a solution to this issue for quite some time now. The bottom line is this: you need to get the number of “shares” from the StumbleUpon service into your script (custom share buttons) via jQuery.getJSON.
Yes, the service has great documentation on this topic , but (for unknown reasons) what is written there does not work. No, well, it works, of course, through the address bar of the browser .. but there is no way to get the value through jQuery.getJSON - an error occurs in the chrome console.
Roughly speaking, if you enter an example from their API in the browser:
http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://www.treehugger.com/
{
"result": {
"url": "http://www.treehugger.com/",
"in_index": true,
"publicid": "1tin26",
"views": 123623,
"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.stumbleupon.com/badge/?url=http://www.treehugger.com/",
"badge_link": "http://www.stumbleupon.com/badge/?url=http://www.treehugger.com/",
"info_link": "http://www.stumbleupon.com/url/www.treehugger.com/"
},
"timestamp": 1443261036,
"success": true
}
badge.getinfo?url=http%3A%2F%2Fwww.treehugger.com%2F&callback=jQuery111203496418842114508_14…:1
Uncaught SyntaxError: Unexpected token :
...
$.getJSON('http://www.stumbleupon.com/services/1.01/badge.getinfo?url=' + encodeURIComponent('http://www.treehugger.com/') + '&callback=?', function(response) {
console.log(response);
});
...
Also, YQL has a limit on requests per day (per hour), and Any Origin is generally paid and can be banned “without trial or investigation” for free use (which is allowed there for review). But with Whatever Origin, almost everything worked out, but the 404th error of the StumbleUpon service constantly comes up in the request instead of the beautiful JSON (which is higher) .. so, also by.
Answer the question
In order to leave comments, you need to log in
Because cross-domain request. Not everything is so simple because of the security policy. Read about CORS and JsonP
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question