Web integration - Missing a code part

Hello there,

I want to create a script to integrate twitch to my wordpress with multiple streamers and display if there are online or not and if they are, activate the stream in an iframe on the right. I have an example which shows exaclty what i want on the homepage of : http://www.fromscratch.gg/

I got the front end part and the behavior script but i’m wondering what part of the API i should call to obtain that

var twitch = {"Voci":{"stream":null,"channel":{"mature":false,"status":"[FR\/EN] Voci <From Scratch> NH NM Viewers @ 14 h","broadcaster_language":"fr","display_name":"Monkifere","game":"World of Warcraft","language":"fr","_id":41998714,"name":"monkifere","created_at":"2013-04-02T15:00:05Z","updated_at":"2017-02-17T16:04:50Z","delay":null,"logo":"https:\/\/static-cdn.jtvnw.net\/jtv_user_pictures\/monkifere-profile_image-0773abb7cf9df983-300x300.jpeg","banner":null,"video_banner":"https:\/\/static-cdn.jtvnw.net\/jtv_user_pictures\/monkifere-channel_offline_image-777e44e232b6b974-1920x1080.png","background":null,"profile_banner":"https:\/\/static-cdn.jtvnw.net\/jtv_user_pictures\/monkifere-profile_banner-fc0de3479947df1b-480.png","profile_banner_background_color":null,"partner":true,"url":"https:\/\/www.twitch.tv\/monkifere","views":373916,"followers":4626,"_links":{"self":"https:\/\/api.twitch.tv\/kraken\/channels\/monkifere","follows":"https:\/\/api.twitch.tv\/kraken\/channels\/monkifere\/follows","commercial":"https:\/\/api.twitch.tv\/kraken\/channels\/monkifere\/commercial","stream_key":"https:\/\/api.twitch.tv\/kraken\/channels\/monkifere\/stream_key","chat":"https:\/\/api.twitch.tv\/kraken\/chat\/monkifere","subscriptions":"https:\/\/api.twitch.tv\/kraken\/channels\/monkifere\/subscriptions","editors":"https:\/\/api.twitch.tv\/kraken\/channels\/monkifere\/editors","teams":"https:\/\/api.twitch.tv\/kraken\/channels\/monkifere\/teams","videos":"https:\/\/api.twitch.tv\/kraken\/channels\/monkifere\/videos"}},"id":"monkifere"}

And can i get a call to have multiple users like this behind var twitch

Thanks a lot !

1 Like

You’d call the Get Live Streams API and render based on the returned JSON. You can supply multiple channel IDs to the request.

Tanks for the reply !
I used this code

var twitch = $.ajax({
    async: false,
    data: dataString,
    dataType: "json",

But the result is not what i expected. How do i render in JSON ?
I’m very new to devellopping and i don’t know how to do x) ?

What is the result you get ? What did you expect ?

Also you didn’t URL encode correctly, the end of the url should be …&stream_type=all, not ?.

Hi there here is a link to the whole code : http://codepen.io/fultr0n/pen/zNQBVr

The thing is if i check it in chrome’s inspector it should look like this for the call part

Like i said i’m a very noob to these scripts!

@fultr0n Kind of off-topic, but for security reasons, you should edit out your Client-ID from your code snippets

Client IDs are public. The only reason to omit them is to prevent verbatim copypasting to own projects.

It doesn’t really bother if people can see my client ID xD.
How can i make this code work ?

It’s JSON. Its a text representation of a basic data structure. You kind of can do whatever you want with it.

Googling something like “javascript json” might help you. You’re rather beyond the scope of the Twitch API now.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.