Code from API streams in my website

function get_url_contents($url){
    $crl = curl_init();
    $timeout = 5;
    curl_setopt ($crl, CURLOPT_URL,$url);
    curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
    $ret = curl_exec($crl);
    curl_close($crl);
    return $ret;
}

Implement that helper function.

Use it as matt_thomas suggested:
$streams = json_decode(get_url_contents("https://api.twitch.tv/kraken/streams/?game=Overwatch&limit=25&client_id=xxxxxxxxxxxxxxxxxxxxxxxx"));

Then just view what it spits out:
print_r($streams);

1 Like