I’m having trouble with a Twitch API call in PHP. My code seems fine and curl doesn’t throw any errors, but I keep getting an empty response instead of actual user data.
public function fetchUserData() {
$apiUrl = $this->TwitchClient->buildUrl("USER_ENDPOINT");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: OAuth " . $this->token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo "Request failed: " . curl_error($ch);
return;
}
curl_close($ch);
$this->userData = json_decode($response);
}
The variable ends up being empty even though no curl errors occur. What could be causing this issue?