I’m having trouble retrieving information from a specific Twitch clip using PHP and the Twitch API. When I try to fetch clip data, I keep getting a 404 error response, even though my code works perfectly for other Twitch API endpoints like video data.
Here’s the code I’m using to fetch the clip details:
$clipEndpoint = 'https://api.twitch.tv/kraken/clips/username/FunnyAwesomeClipSlug123';
$appClientId = 'your_client_id_here';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_HTTPHEADER => array(
'Client-ID: ' . $appClientId
),
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $clipEndpoint
));
$result = curl_exec($curl);
curl_close($curl);
$data = json_decode($result, TRUE);
var_dump($data);
The weird thing is that when I use the same approach for fetching video information, everything works as expected:
$videoEndpoint = 'https://api.twitch.tv/kraken/videos/987654321';
// same curl configuration
What could be causing this 404 error specifically for clip data? Am I using the wrong API endpoint format or missing some required parameters?