Is not required with helix.
Your URL is constructed wrong, as documented
it’s just name not game_name
This should work, and is a little cleaner and tests for errors than yours.
<?php
$ch = curl_init('https://api.twitch.tv/helix/games?name=Minecraft')
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Client-ID: ' . $clientId
));
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if ($info['http_code'] == 200) {
$resp = json_decode($result);
if (json_last_error() == JSON_ERROR_NONE) {
if ($resp->data && count($resp->data) == 1) {
$gameID = $resp->data[0]->id;
// go and do other stuff
} else {
echo 'Not one game returned';
}
} else {
echo 'JSON Parse Error';
}
} else {
echo 'Failed';
}