Automatic detection

Hi everyone!
I apologize for my English because I’m French …

I need your help because I’m not very good at coding and so I do not really understand the API.
I would like to automatically detect when a stream is online or offline. When online, I want an image appears and when it is offline, another image.

I would do it in jQuery rather than php. After if we are forced with php, I would do in php.

Thank you very much for your help. :slight_smile:

It’s not automatic, but here is what you can do to check.

Streams.md

To extend on that… basically you have to request the streams by channel name and if the stream is live it will be returned in the response otherwise it wont be. That’s how you know if it is online or offline.

You can also use https://github.com/Fugiman/Twitch-Channel-Status to help you get started with your solution.

Yes but on my website there will be several streameurs. What I want to do is a homepage with a picture on it for each streameur: this one if the stream is offline: http://image.noelshack.com/fichiers/2015/10/1425396841-blaf-deco .png
and this one if the stream is online: http://image.noelshack.com/fichiers/2015/10/1425396882-blaf-en-live.png
But there will be more images like this one on the home page. So his scripts I put them on the homepage but how to detect the correct channel?
I do not know if you understand me …
You want me to show you my HTML and CSS for you to understand better?

Again sorry for my english …

The script I linked to you does this for you, and it explains how to use it. Specifically, you’d do something like this:

<img data-twitch-channel="riotgames" data-offline-image="riotgames.png" data-online-image="riotgames-live.png">
<img data-twitch-channel="lirik" data-offline-image="lirik.png" data-online-image="lirik-live.png">
<img data-twitch-channel="beyondthesummit" data-offline-image="beyondthesummit.png" data-online-image="beyondthesummit-live.png">

<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.rawgit.com/Fugiman/Twitch-Channel-Status/1d74252edf89110507cbf3088f9c3eaa38fac9d3/twitch-channel-status.min.js"></script>

Does that make it clear?

1 Like

Thank you so much !!!

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