Пример #1
0
/** 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;
}
/** Display live stream title instead of 'online'. */
if (isset($_GET['title']) && strtolower($_GET['title']) === 'true') {
    if (!empty($api_request->result->title)) {
        $online_message = $api_request->result->title;
    }
}
/** Check to auto link. */
if (isset($_GET['link']) && strtolower($_GET['link']) === 'true') {
    $link = 'https://www.livecoding.tv/' . urlencode($channel) . '/';
} else {
    $link = '';
}
/** Output svg image. */
header("Content-type:image/svg+xml");
if ($api_request->result->is_live) {
    echo get_badge_svg('livecoding.tv', $online_message, '#4c1', $link);
} else {
    echo get_badge_svg('livecoding.tv', $offline_message, '#e05d44', $link);
}
Пример #2
0
/** 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' => $channel));
/** Bail if API isn't authorized. */
if (!$lctv_api->is_authorized()) {
    header("Content-type:image/svg+xml");
    echo get_badge_svg('lctv last streamed', 'error', '#e05d44');
    exit;
}
/** Get users latest videos. */
$api_request = $lctv_api->api_request('v1/user/videos/latest/');
/** Bail on error. */
if ($api_request === false || isset($api->request->detail)) {
    header("Content-type:image/svg+xml");
    echo get_badge_svg('lctv last streamed', 'error', '#e05d44');
    exit;
}
/** Check to auto link. */
if (isset($_GET['link']) && strtolower($_GET['link']) === 'true') {
    $link = 'https://www.livecoding.tv/' . urlencode($channel) . '/';
} else {
    $link = '';
}
/** Output svg image. */
header("Content-type:image/svg+xml");
if (is_array($api_request->result) && !empty($api_request->result[0]->creation_time)) {
    echo get_badge_svg('lctv last streamed', date('M j, Y', strtotime($api_request->result[0]->creation_time)), '#4c1', $link);
} else {
    echo get_badge_svg('lctv last streamed', 'never', '#e05d44', $link);
}
Пример #3
0
$channel = strtolower($_GET['channel']);
/** 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' => $channel));
/** Bail if API isn't authorized. */
if (!$lctv_api->is_authorized()) {
    header("Content-type:image/svg+xml");
    echo get_badge_svg('lctv followers', 'error', '#e05d44');
    exit;
}
/** Get user followers. */
$api_request = $lctv_api->api_request('v1/user/followers/');
/** Bail on error. */
if ($api_request === false || isset($api_request->result->detail)) {
    header("Content-type:image/svg+xml");
    echo get_badge_svg('lctv followers', 'error', '#e05d44');
    exit;
}
/** Count number of followers. */
$follower_count = count($api_request->result);
/** Check to auto link. */
if (isset($_GET['link']) && strtolower($_GET['link']) === 'true') {
    $link = 'https://www.livecoding.tv/' . urlencode($channel) . '/';
} else {
    $link = '';
}
/** Output svg image. */
header("Content-type:image/svg+xml");
echo get_badge_svg('lctv followers', $follower_count, '#4c1', $link);
Пример #4
0
}
/** Get live streaming info for a channel. */
$api_request = $lctv_api->api_request('v1/scheduledbroadcast/?limit=500');
/** Bail on error. */
if ($api_request === false || isset($api_request->result->detail)) {
    header("Content-type:image/svg+xml");
    echo get_badge_svg('livecoding.tv', 'error', '#e05d44');
    exit;
}
/** Get scheduled streams and search for channel name. */
$next_stream = '';
$api_request->result->results = array_reverse($api_request->result->results);
foreach ($api_request->result->results as $scheduled) {
    if (strpos($scheduled->livestream, $channel) !== false) {
        $next_stream = strtotime($scheduled->start_time_original_timezone);
        break;
    }
}
/** Check to auto link. */
if (isset($_GET['link']) && strtolower($_GET['link']) === 'true') {
    $link = 'https://www.livecoding.tv/' . urlencode($channel) . '/';
} else {
    $link = '';
}
/** Output svg image. */
header("Content-type:image/svg+xml");
if ($next_stream) {
    echo get_badge_svg('next stream', date('M j @ g:i a', $next_stream), '#4c1', $link);
} else {
    echo get_badge_svg('next stream', 'no stream scheduled', '#e05d44', $link);
}
Пример #5
0
if (!$lctv_api->is_authorized()) {
    header("Content-type:image/svg+xml");
    echo get_badge_svg('lctv viewers', '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('lctv viewers', '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;
    $api_request->result->viewers_live = 0;
}
/** Check to auto link. */
if (isset($_GET['link']) && strtolower($_GET['link']) === 'true') {
    $link = 'https://www.livecoding.tv/' . urlencode($channel) . '/';
} else {
    $link = '';
}
/** Output svg image. */
header("Content-type:image/svg+xml");
if ($api_request->result->is_live) {
    echo get_badge_svg('lctv viewers', $api_request->result->viewers_live, '#4c1', $link);
} else {
    echo get_badge_svg('lctv viewers', $api_request->result->viewers_live, '#e05d44', $link);
}