我需要编写一个程序来显示频道的用户,并在必要时切换到频道的流。
我尝试了教程中的代码,但是我无权访问 API。
$(document).ready(function(){
var url ="https://api.twitch.tv/kraken/streams/freecodecamp";
$.getJSON(url,function(data1){
});
})
此连接 url 不起作用,因为显然它需要某种用户编号。我想知道如何得到它。即使有标准的错误请求:
curl -i https://api.twitch.tv/kraken
HTTP/1.1 400 Bad Request
Accept-Ranges: bytes
Access-Control-Allow-Headers:
Access-Control-Allow-Methods:
Access-Control-Allow-Origin: *
Age: 0
Cache-Control: max-age=0, private, must-revalidate
Content-Type: application/json; charset=utf-8
Date: Wed, 07 Dec 2016 16:00:20 GMT
Server: nginx
Status: 400 Bad Request
Vary: Accept-Encoding
Via: 1.1 varnish
X-API-Version: 3
X-MH-Cache: rails-varnish-api-aws-0ae1f1a3c7c2916de; M
X-Request-Id: 7c566325f3f52de40f2625c1d083af60
X-UA-Compatible: IE=Edge,chrome=1
X-Varnish: 713591920
Content-Length: 71
Connection: keep-alive
{"error":"Bad Request","status":400,"message":"No client id specified"}
尝试使用
twitch-js-sdk(链接)。工作示例: