Exemplo n.º 1
0
function delegate($action)
{
    //cleanCache();
    $ds = dataSetName($_GET);
    $data = loadFromCache($ds);
    if ($data) {
        echo $data;
        exit(0);
    }
    switch ($action) {
        //Twitter
        case 'topTweets':
            $data = topTweets();
            break;
            //Google Analytics
        //Google Analytics
        case 'chart':
            $data = getChart();
            break;
            //Events
        //Events
        case 'events':
            $data = getEvents();
            break;
            //Statistics
        //Statistics
        case 'stats':
            $data = getStatistics();
            break;
            //Social badge
        //Social badge
        case 'social':
            $data = generateSocialBadge();
            break;
    }
    if (!empty($data)) {
        $val = storeInCache($ds, output($data));
        if (!$val) {
        }
    }
    echo output($data);
    exit(0);
}
Exemplo n.º 2
0
function getTopPostEmbedded($id, $type)
{
    switch ($type) {
        case 'twitter':
            //Twitter
            $post = topTweets($id, 1);
            if (isset($post[0])) {
                $embed = tweetEmbeed($post[0]->id_str);
                if (isset($embed->html)) {
                    return $embed->html;
                }
                return "<script>console.warn('Twit: " . serialize($embed) . "')</script>";
            } else {
                return "<script>console.warn('Twit: Top post not found')</script>";
            }
            break;
        case 'facebook':
            //FB
            $post = getTopFBPosts($id, 1);
            if (isset($post[0])) {
                return FBembeed(getFBlink($post[0]));
            } else {
                return "<script>console.warn('FB: Top post not found')</script>";
            }
            break;
        case 'instagram':
            $post = getTopIGMedia($id, 1);
            if (isset($post[0])) {
                $embed = igEmbed($post[0]->link);
                return $embed->html;
            } else {
                return "<script>console.warn('IG: Top post not found')</script>";
            }
            break;
    }
    return null;
}
Exemplo n.º 3
0
function topTweetEvents($account, $count = 10)
{
    $tweets = topTweets($account, $count);
    if (!isset($tweets)) {
        return array();
    }
    $tevents = array();
    foreach ($tweets as $key => $t) {
        $teve = array();
        $time = strtotime($t->created_at);
        $sdate = date("l F jS", $time);
        $ebed = tweetEmbeed($t->id_str);
        $teve['title'] = "Tweet from {$sdate}";
        $teve['type'] = "Top Tweets";
        $teve['source'] = "Twitter";
        if (isset($ebed->html)) {
            $teve['html'] = $ebed->html;
        } else {
            $teve['html'] = "<script>console.warn('Twit: " . serialize($ebed) . "')</script>";
        }
        $teve['score'] = $key;
        $teve['url'] = "https://twitter.com/statuses/" . $t->id_str;
        $teve['points'] = $t->score;
        $teve['timestamp'] = $time * 1000;
        //	$teve['username'] = '******' . $t->user->screen_name;
        array_push($tevents, $teve);
    }
    return $tevents;
}