opt*_*con 2 javascript node.js soundcloud
我有一些代码试图从Soundcloud API获取JSON结果.
我注册了一个应用程序,获得了客户端ID等等,我正在尝试拨打这样的电话:
var querystring = require('querystring');
var http = require('http');
var addr = 'http://api.soundcloud.com/resolve.json?url=http://soundcloud.com/matas/hobnotropic&client_id=XXXXX';
var options = {
hostname: "api.soundcloud.com",
path: "/resolve.json?url=http://soundcloud.com/matas/hobnotropic&client_id=XXXXXx",
method: "GET",
headers: {
"Content-Type": "application/json"
}
}
var request = http.get(options, function(response) {
response.setEncoding('utf8');
response.on('data', function(chunk) {
console.log(chunk);
});
});
Run Code Online (Sandbox Code Playgroud)
这会产生如下结果:
{"status":"302 - Found","location":"https://api.soundcloud.com/tracks/49931.json?client_id=xxxx"}
Run Code Online (Sandbox Code Playgroud)
当我在Chrome中使用相同的网址时,我会获得正确的JSON信息.如何从服务器端脚本正确地进行此调用?
| 归档时间: |
|
| 查看次数: |
5133 次 |
| 最近记录: |