2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: bd7158d8c442eddfaeb5bd1f
|
2020-12-16 00:37:30 -07:00
|
|
|
|
title: 使用Twitch JSON API
|
2018-10-10 18:03:03 -04:00
|
|
|
|
challengeType: 3
|
|
|
|
|
videoUrl: ''
|
2021-01-13 03:31:00 +01:00
|
|
|
|
dashedName: use-the-twitch-json-api
|
2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --description--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
**目标:** 构建一个功能类似于此的[CodePen.io](https://codepen.io)应用程序: [https](https://codepen.io/freeCodeCamp/full/Myvqmo/) **:** [//codepen.io/freeCodeCamp/full/Myvqmo/](https://codepen.io) 。完成以下[用户故事](https://en.wikipedia.org/wiki/User_story) 。使用您需要的任何库或API。给它你自己的个人风格。 **用户故事:** 我可以看到freeCodeCamp当前是否在Twitch.tv上流式传输。 **用户故事:** 我可以点击状态输出并直接发送到freeCodeCamp的Twitch.tv频道。 **用户故事:** 如果Twitch用户当前正在播放,我可以看到有关他们正在播放的内容的其他详细信息。 **提示:** 请参阅[http://forum.freecodecamp.org/t/use-the-twitchtv-json-api/19541上](http://forum.freecodecamp.org/t/use-the-twitchtv-json-api/19541)对Twitch.tv的JSONP API的示例调用。 **提示:** 有关此API调用的相关文档位于: [https](https://dev.twitch.tv/docs/v5/reference/streams/#get-stream-by-user) : [//dev.twitch.tv/docs/v5/reference/streams/#get-stream-by-user](https://dev.twitch.tv/docs/v5/reference/streams/#get-stream-by-user) 。 **提示:** 这是定期传输的人的Twitch.tv用户名数组: `["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"]` **更新:** 由于[此处](https://blog.twitch.tv/client-id-required-for-kraken-api-calls-afbb8e95f843#.f8hipkht1)解释的API使用条件发生变化,Twitch.tv现在需要API密钥,但我们已经构建了一种解决方法。使用[https://wind-bow.glitch.me/twitch-api](https://wind-bow.glitch.me)而不是twitch的API基本URL(即`https://api.twitch.tv/kraken),您仍然可以获取帐户信息,而无需注册API密钥。如果卡住,请记得使用`[Read-Search-Ask](https://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck-coding/19514) 。完成后,单击“我已完成此挑战”按钮并包含指向CodePen的链接。您可以通过Facebook上的朋友分享您的项目反馈。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --solutions--
|
2020-08-13 17:24:35 +02:00
|
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|