I’m not sure what I’m missing here. My goal is get a random clip by specific user. Data returned is NULL or more specifically:
string(27) "{"data":[],"pagination":{}}"
Here’s my code (with CLIENT_ID and ID replaced):
$ch = curl_init('https://api.twitch.tv/helix/clips?broadcaster_id=ID');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Client-ID: CLIENT_ID',
'Authorization: Bearer '.$autharr->access_token
));
$r = curl_exec($ch);
$i = curl_getinfo($ch);
curl_close($ch);
if ($i['http_code'] == 200) {
$data = json_decode($r);
if (json_last_error() == JSON_ERROR_NONE) {
var_dump($r);
} else echo 'Failed with ' . $r;
} else echo 'Failed with ' . $r;
I get the same no data with other examples as well.