/** Bail if no channel name. */ if (!isset($_GET['channel']) || empty($_GET['channel'])) { exit; } /** Set the channel name. */ $channel = strtolower($_GET['channel']); /** Set the online message. */ $online_message = isset($_GET['online']) && !empty($_GET['online']) ? $_GET['online'] : 'online'; /** Set the offline message. */ $offline_message = isset($_GET['offline']) && !empty($_GET['offline']) ? $_GET['offline'] : 'offline'; /** Initialize. */ require_once 'lctv_badges_init.php'; /** Load the API. */ $lctv_api = new LCTVAPI(array('data_store' => LCTVAPI_DATA_STORE_CLASS, 'client_id' => LCTV_CLIENT_ID, 'client_secret' => LCTV_CLIENT_SECRET, 'user' => LCTV_MASTER_USER)); /** Bail if API isn't authorized. */ if (!$lctv_api->is_authorized()) { header("Content-type:image/svg+xml"); echo get_badge_svg('livecoding.tv', 'error', '#e05d44'); exit; } /** Get live streaming info for a channel. */ $api_request = $lctv_api->api_request('v1/livestreams/' . urlencode($channel) . '/'); /** Bail on error. */ if ($api_request === false) { header("Content-type:image/svg+xml"); echo get_badge_svg('livecoding.tv', 'error', '#e05d44'); exit; } /** API returned an error. This happens if user is not streaming. */ if (isset($api_request->result->detail)) { $api_request->result->is_live = false;