How to Get Channel Information

If you are familiar with file_get_contents, you can sub it out with something like this:

<?php


/* file_get_contents replaced with curl function - Add this function and replace any use of file_get_contents with file_get_contents_curl */
function file_get_contents_curl($url) {
    $curlHeader = array(
        "Client-ID: xxxxxxxxxxxxxxxxxxxxxxxxxx",    /* SET CLIENT ID HERE */
        "Accept: application/vnd.twitchtv.v5+json",
        "Authorization: OAuth xxxxxxxxxxxxxxxxxxxxxxxxxxx"
    );
    $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, $curlHeader);
    $data = curl_exec($ch);
    if (!curl_errno($ch)) {
      switch ($http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE)) {
    case 200:  # OK
      break;
    default:
      echo 'Unexpected HTTP code: ', $http_code, "\n";
  }
}
    curl_close($ch);
    return $data;
}

?>

Remove the OAuth for your purpose, it’s just there for the example.