I attempted to use delay to detect the stream as i figure if the delay is 0 they are offline. This being because i have found there is always a delay between the host and the end user… in my experience anyway.
Im not the best coder in the galaxy so im sure ill be missing something but i had a check through the git and couldnt find a solution. Also if there is another method of getting multiple streams details in as few JSON calls as possible (to lower loading times of site) I would love to know.
The users/channels API does not tell you if they are live or not. For that you should use the Streams API. To get all live streams a user is following you can use /kraken/streams/followed, or if you just want multiple channels in the response you can use /kraken/streams?channel=riotgames,beyondthesummit.
For anyone wondering the backslashes ( \ ) before the quotation marks ( " ) makes php ignore the quotes programmed meaning and just include them in the “echo” command.
the { after foreach is required, however you seem to be missing the closing }. I’m unsure what you mean by “can’t get it to close right”, can you clarify what problem you’re having?
Hi, the code is correct but this api with multi channel doesn’t allowed to display offline. If i used https://api.twitch.tv/kraken/streams/"$value" for multi channel’s online/offline, the page takes a long time to load. Any idea?
I used the code from here to let the video embed based on the three names on top. However, when i enter this code into a php file and i let it include into my htmlpage it just doesn’t pop up and blocks anything that has to go under the phpinclude.
Does it give any error? One possibility is that your host has blocked file_get_contents from accessing remote URLs, in which case you’d have to use CURL to fetch the data.
seemed to do it, in case others have the same problem i’ll keep this code here. Only thing in this code that doesn’t work is that if every of the streamers is offline the
if($dataArray['streams'] == null or $dataArray['streams'] == "")
{
echo "<p>There are currently no live streams.</p>";
echo "<p>Refresh this page to retrieve live streams or check back later!</p>";
}
This will output the above if $dataArray[‘streams’] returns null or “”.