Last active
October 14, 2016 07:28
-
-
Save SirDarcanos/65e56f4d5618b4218acf09b8710df9a1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function is_streamer_live( $channel, $client_id ) { | |
// Get current status | |
$url = 'https://api.twitch.tv/kraken/streams/' . esc_html( trim( $channel, '/' ) ) . '?client_id=' . esc_html( $client_id ); | |
$response = wp_remote_get( $url ); | |
if ( ! is_wp_error( $response ) && $response['response']['code'] === 200 ) { | |
$body = json_decode( wp_remote_retrieve_body( $response ) ); | |
if ( empty( $body->stream ) ) { | |
return false; | |
} else { | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment