PHP version shouldn’t be a factor, as it will enforce a specific version of the cURL module anyway.
You could try adding a
$info = curl_getinfo($handle);
print_r($info);
Before the curl_close
It might be that for whatever reason your PHP install can’t communicate with the internet.
Or this could be a SSL error (since we didn’t do a HTTP Code check)
SSL error could be: SSL local Cert bundle missing or out of date.
Your server clock is out too far and can’t verify the connection.
The output of curl_getinfo should provide more information.
It’s also a good idea to do HTTP Code checking whenever you do a request, rather than blindly bassing back the response.
So here: twitch_misc/index.php at main · BarryCarlyon/twitch_misc · GitHub
// fetch the data
$r = curl_exec($ch);
// get the information about the result
$i = curl_getinfo($ch);
// close the request
curl_close($ch);
if ($i['http_code'] == 200) {
$token = json_decode($r);
// always a good idea to check the JSON parsed correctly
if (json_last_error() == JSON_ERROR_NONE) {
I check the HTTP Code and I check ifthe JSON actually decoded as expected