{'client_id'}; $curl_h = curl_init('https://api.twitch.tv/helix/users?login=' . $_GET["user"]); curl_setopt($curl_h, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $twtoken, 'Client-ID: ' . $client_id, ) ); curl_setopt($curl_h, CURLOPT_RETURNTRANSFER, true); $json = json_decode(curl_exec($curl_h)); $userid = $json->{'data'}[0]->{'id'}; $username = $json->{'data'}[0]->{'display_name'}; if ($userid != null) { if ($_SERVER['PATH_INFO'] == "/werfolgt") { echo "

" . $username . " wird gefolgt von:

"; getFollows("from"); } else if ($_SERVER['PATH_INFO'] == "/wemfolgt") { echo "

" . $username . " folgt:

"; getFollows("to"); } } else { echo "Der Nutzer " . $_GET["user"] . " existiert nicht."; } } else { echo "Nutzernamen angeben: ?user=(twitch username) an den Link anhängen"; } } else { echo "Wer folgt...
Wem folgt...
"; } function getFollows($dir) { $cursor = null; do { $json = req($cursor, $dir); $cursor = $json->{'pagination'}->{'cursor'}; foreach ($json->{'data'} as $fol) { echo "" . $fol->{$dir . '_name'} . "
"; } } while($cursor != null); } function req($cursor, $dir) { global $client_id; global $userid; global $dctoken; $side = "from"; if ($dir == "from") $side = "to"; if ($cursor == null) { $curl_h = curl_init('https://api.twitch.tv/helix/users/follows?' . $side . '_id='. $userid . '&first=100'); } else { $curl_h = curl_init('https://api.twitch.tv/helix/users/follows?' . $side . '_id=' . $userid .'&first=100&after=' . $cursor); } curl_setopt($curl_h, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $dctoken, 'Client-ID: ' . $client_id, ) ); curl_setopt($curl_h, CURLOPT_RETURNTRANSFER, true); return json_decode(curl_exec($curl_h)); }