<?php
error_reporting(-1); ini_set('display_errors', 'On'); 
error_reporting(E_ALL);
ini_set("display_errors", 1);
if($stmt = $mysqli -> prepare("SELECT username FROM Twitch WHERE uid = ?")){
	$stmt -> bind_param("i", $userid);
	$stmt -> execute();
	$stmt -> bind_result($TwitchUsername);
	$stmt -> fetch();
	$stmt -> close();
}

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "https://api.twitch.tv/kraken/users/".$TwitchUsername."/follows/channels"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$jsonreturn = json_decode(curl_exec($ch), true);
//$jsonreturn = curl_exec($ch);
?>
<div class="col-lg-12">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>Twitch Integratie</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                    <i class="fa fa-wrench"></i>
                </a>
                <ul class="dropdown-menu dropdown-user">
                    <li><a href="twitch.php?i=configuration">Configure Twitch Account</a></li>
                </ul>
                <a class="close-link">
                    <i class="fa fa-times"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <label>Ingelogd als: <?php print($TwitchUsername); ?> </label>
            <br />
            <label>Aan het volgen:</label>
            <br />
            <label><?php
            for($x = 0; $x < count($jsonreturn["follows"]); $x++ )
            {
                echo $jsonreturn["follows"][$x]["channel"]["display_name"]."<br />";
            }
            ?></label>
        </div>
    </div>
</div>