Grooveshark公共API - 找不到方法

时间:2013-03-04 09:12:26

标签: jquery ajax grooveshark

我正在使用Jquery将JSON数据发送到Grooveshark API以获取搜索结果,但这是我得到的结果 -

{"errors":[{"code":2,"message":"Method not found."}]}

这是触发groovehark API的一段代码。我无法弄清楚这个问题,任何帮助都会很棒。

$.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!"); 
    }

});

1 个答案:

答案 0 :(得分:0)

所以,我还没有到那里,但我想知道你是如何获得请求URL末尾的secret_code。

https://github.com/fastest963/GroovesharkAPI-PHP/blob/master/gsAPI.php#L1044翻译看来,当您申请公共API密钥时,sig不是您的密码。

相反,它是你在ajax调用中发送到数据参数的dict的HMAC(md5)。我找到https://code.google.com/p/crypto-js/#HMAC并使用它来生成sig,将你发送的dict作为数据arg传入$ .ajax,并使用我的秘密从gs api签名。

我正在尝试调用启动会话,但我最终会使用

Object { readyState=0, status=0, statusText="error"}

信息较少,但我很确定这个网址不是你的秘密。

相关问题