Created
April 11, 2020 17:04
-
-
Save seanslater/b97ce2b3f87b486424bc23eecbbe9175 to your computer and use it in GitHub Desktop.
Twitch API - Check to see if User ID is live
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$TWITCH_API_KEY = ''; // your Client ID | |
$TWITCHUSERID = ''; // Twitch User ID number | |
$url = 'https://api.twitch.tv/helix/streams?user_id='.$TWITCHUSERID; | |
$ch = curl_init(); | |
$headers=['Client-ID: '.$TWITCH_API_KEY]; | |
curl_setopt($ch, CURLOPT_URL,$url); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |
$result = curl_exec ($ch); | |
curl_close ($ch); | |
$json_array = json_encode($result); | |
$array = json_decode($result, true); | |
echo $array["data"][0]["type"]; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment