Reputation: 113
I'm using Jquery to send JSON data to the Grooveshark API to get search results, but this is the result I get -
{"errors":[{"code":2,"message":"Method not found."}]}
This is piece of code which triggers the grooveshark API. I cannot figure out the problem with this, any help would be great.
$.ajax({
type: "POST",
url: 'http://api.grooveshark.com/ws3.php?sig=secret_code',
data: {
"method":"getSongSearchResults",
"header":{"wsKey":"secret_key"},"parameters":{"query":"megadeth hangar 18","country":"1","limit":"2","offset":""}
},
dataType: 'jsonp',
crossDomain: true,
async: false,
success: function () {
alert("success!");
}
});
Upvotes: 4
Views: 658
Reputation: 2993
So, I'm not all the way there yet, but I wonder how you're getting the secret_code that goes on the end of your request URL.
Translating from https://github.com/fastest963/GroovesharkAPI-PHP/blob/master/gsAPI.php#L1044 it seems that the sig is NOT your secret code that you get when you apply for a public API key.
Instead it's a HMAC(md5) of the dict that you're sending in to your data parameter in your ajax call. I found https://code.google.com/p/crypto-js/#HMAC and am using that to produce the sig by passing in that dict that you're sending in as your data arg to $.ajax, and am signing it with my secret from the gs api.
I am trying to call start session, but I end up with
Object { readyState=0, status=0, statusText="error"}
which has less information, but I'm pretty sure it's not your secret that goes on that URL.
Upvotes: 0