Twitch API检查频道是否有效

I found a way to check if a channel is live on Twitch. I have been getting a error, "Trying to get property of non-object" for the "return ( ! is_null( $Request->stream ) ) ? TRUE : FALSE;" line. Everything seems set. I would appreciate any suggestions/help.

    <?php
function is_channel_live( $channel ) {
    $Request = json_decode( @file_get_contents( 'https://api.twitch.tv/kraken/streams/' . $channel ) );
    return ( ! is_null( $Request->stream ) ) ? TRUE : FALSE;
}

if (is_channel_live("thegamingbelugas")) {
    echo "LIVE";
}

?>

Use $request with lowercase:

$request = json_decode( @file_get_contents( 'https://api.twitch.tv/kraken/streams/' . $channel ) );
return ( ! is_null( $request->stream ) ) ? TRUE : FALSE;

instead of $Request. Twitch API doesn't understand the uppercase Request.

You also need a client ID for twitch API connections - which can be received by registering your application at https://www.twitch.tv/settings/connections.