I’m trying to do a “simple” php-cURL request to the twitch api and it’s not returning anything at all. No errors, just nothing.
Here’s my code, help is much appreciated c:
<?php
// url/followage.php?user=$(touser)&channel=CHANNELNAME
$user;
$channel;
$clientid = "xxxxx";
if (isset($_GET['user'])){
$user = $_GET['user'];
} else {
echo "Invalid query - user not supplied";
}
if (isset($_GET['channel'])){
$channel = $_GET['channel'];
} else {
echo "Invalid query - channel not specified";
}
$url = "https://api.twitch.tv/kraken/users/" . $user . "/follows/channels/" . $channel;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Client-ID: " . $clientid, "Accept: application/vnd.twitchtv.v3+json"));
$data = curl_exec($ch);
curl_close($ch);
echo $data;
?>