OpenSubtitles API - SearchSubtitles不返回任何数据

时间:2014-10-17 11:52:04

标签: javascript api xml-rpc

我正在关注此tutorial来对OpenSubtitles进行API调用。我使用Javascript,mimic.js作为XML-RPC客户端。为什么以下代码不起作用?

var loginRequest= new XmlRpcRequest("http://api.opensubtitles.org/xml-rpc", "LogIn");
loginRequest.params = (['', '', 'eng', 'OS Test User Agent']);
var response1= loginRequest.send();
var token=String(response1.parseXML().token);
console.log(token);

var searchRequest = new XmlRpcRequest("http://api.opensubtitles.org/xml-rpc", "SearchSubtitles");
searchRequest.params= [token, [['query= South Park', 'season= 1', 'episode=1']]];
var results = searchRequest.send();
console.log(results.parseXML());

作为回报,我没有得到任何数据(数据:false)。令牌部分工作正常。

1 个答案:

答案 0 :(得分:3)

如果有人需要,会在下面添加搜索代码。请注意,查询在对象中传递给addParam:

var searchRequest = new XmlRpcRequest("http://api.opensubtitles.org/xml-rpc", "SearchSubtitles");
searchRequest.addParam(token);
searchRequest.addParam([{query: 'South Park'}]);
var results = searchRequest.send();
console.log(results.parseXML());