Basic PHP cURL to fetch a URL and process the response
<?php
$ch = curl_init('https://api.twitch.tv/helix/streams?user_login=Channel_name');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Client-ID: MyClientId'
));
$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if ($info['http_code'] == 200) {
$data = json_decode($data);
var_dump($data);
} else {
echo 'Failed with ' . $info['http_code'];
}
See also
Google Search: php fetch from api
Second Result: https://stackoverflow.com/questions/33302442/get-info-from-external-api-url-using-php/33303776