jQuery(function($) {
$.ajax({
url: "http://www.podbean.com/api2/public/filesPlays",
type:"GET",
data:{"blogId":"63614","query":[{"file":"207_Field_Hospital.mp3","w":"ccb77541"}]},
dataType:"json",
success: function(result) {
if(result.code =="200")
{
$.each(result.data, function(id,count){
id = id.replace(/\./g,"_");
if(count >0)
{
$(".hits_"+id).text(count);
}
else
{
$(".hits_"+id).parent(".hits").prev("span").remove();
$(".hits_"+id).parent(".hits").remove();
}
});
}
}
});
});
I've been trying to use "requests" in Python (http://docs.python-requests.org/en/master/user/quickstart/#passing-parameters-in-urls) to get the number of "hits" but I don't know how to pass it json. My failed attempt was:import requests
data = {"blogId":"63614","query":[{"file":"207_Field_Hospital.mp3","w":"ccb77541"}]}
r = requests.get("http://www.podbean.com/api2/public/filesPlays", json=data)
print(r.url)
print(r.status_code)
print(r.text)
If "requests" can't do it, I'm open to doing it another way with Python...
ASKER
ASKER
jQuery (Core) is a cross-browser JavaScript library that provides abstractions for common client-side tasks such as Document Object Model (DOM) traversal, DOM manipulation, event handling, animation and Ajax. jQuery also provides a platform to create plugins that extend jQuery's capabilities beyond those already provided by the library.
TRUSTED BY
Open in new window
It is complaining of the blog id, but I think it is matter of correct structure of json.I did not find documentation on this API to fix it for you.