Skip to content

Instantly share code, notes, and snippets.

@SiR-DanieL
Last active Oct 14, 2016
Embed
What would you like to do?
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