Need to add client_id to old script

I have for you, a functioning example that will switch file_get_contents with cURL and allow you to set the Client ID in the header of the request.

This will set you set the Client ID once and attach it to the function file_get_contents_curl. In the long run I’d think this would make life simpler.

<?php

$clientID = array(
‘Client-ID: 0000000000000000000000000000000’
);

function file_get_contents_curl($url) {
$ch = curl_init();

curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);       
curl_setopt($ch, CURLOPT_HTTPHEADER, $clientID);
$data = curl_exec($ch);
curl_close($ch);
return $data;

}

function StreamInfo($channels) {
$channel = implode(‘,’, $channels);
$streamData = json_decode(@file_get_contents_curl(‘https://api.twitch.tv/kraken/streams?channel=".$channel’), true);
return $streamData;
}

?>