I can retrieve games by id but I get a 400 bad request when I try to get them using a name string. The names I’ve been trying have come directly from the name field of the request when I do it by id so there shouldn’t be an issue with matching.
using php the function is : (with TWITCH_API_ID defined eariler)
function getTwitchGameDataByName($gameName){
// using new TWITCH API
try{
$url = "https://api.twitch.tv/helix/games?name=$gameName";
$ch = curl_init();
$headers=array('Client-ID: '.TWITCH_API_ID);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec ($ch);
//echo $result;
curl_close ($ch);
if (!empty($result)){
return json_decode($result, true);}
}
catch (Exception $ex){
return NULL;
}
}
if you want to test it use the parameter
$gameName = “Company of Heroes: Tales of Valor”;
Also ‘Company of Heroes 2’ doesn’t work but strangely ‘RimWorld’ and ‘HomeWorld’ do is there a space issue here ?