Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $streamChannel = "kamiiq";
- $url = "https://api.twitch.tv/kraken/streams?channel=" . $streamChannel;
- $clientID = '6x31cwwskz31pmkfibymz8un59icd2';
- $ch = curl_init();
- function file_get_contents_curl($url) {
- curl_setopt_array($ch, array(
- CURLOPT_HTTPHEADER => array(
- 'Client-ID: ' . $clientID
- ),
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_URL => $url . $streamName,
- CURLOPT_AUTOREFERER => TRUE,
- CURLOPT_HEADER => FALSE,
- CURLOPT_RETURNTRANSFER => TRUE,
- CURLOPT_FOLLOWLOCATION => TRUE,
- CURLOPT_HTTPHEADER => $clientID
- ));
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
- }
- $json_array = json_decode(file_get_contents_curl($url), true);
- if(isset($json_array['streams'][0]['channel'])) {
- echo '( ͡° ͜ʖ ͡°)';
- } else {
- echo 'nope';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement