Skip to content

Instantly share code, notes, and snippets.

@SiR-DanieL
Last active October 14, 2016 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiR-DanieL/65e56f4d5618b4218acf09b8710df9a1 to your computer and use it in GitHub Desktop.
Save SiR-DanieL/65e56f4d5618b4218acf09b8710df9a1 to your computer and use it in GitHub Desktop.
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