John Smith
John Smith

Reputation: 6207

Twitch TV channel information: doesnt work

I want to get information about a channel, is it online at the moment or not:

$stream_list = ...;

$mycurl = curl_init();

curl_setopt ($mycurl, CURLOPT_HEADER, 0);
curl_setopt ($mycurl, CURLOPT_RETURNTRANSFER, 1);

//Build the URL
$url = "http://api.justin.tv/api/stream/list.json?channel=" . $stream_list;
curl_setopt ($mycurl, CURLOPT_URL, $url);

$web_response =  curl_exec($mycurl);

but thats always return with an empty array. I saw many example based on it - mine wont work, what am I doing wrong?

Upvotes: 1

Views: 323

Answers (2)

Rawr
Rawr

Reputation: 2224

It returns an empty array if the channel is not live.

Upvotes: 1

Steven V
Steven V

Reputation: 16595

An empty array probably means nothing was found with the stream list you provided.

I used http://api.justin.tv/api/stream/list.json?channel=beyondthesummit,towelliee and was able to get an array from the API, and then I used http://api.justin.tv/api/stream/list.json?channel=foobar and got an empty JSON array back.

I'd make sure $stream_list has the value you expect. And if it does, try removing the channel filter completely to see if you get results.

Upvotes: 2

Related Questions