Пример #1
0
function getMultiTopPosts($acts, $type, $count = 5)
{
    $posts = array();
    foreach ($acts as $key => $a) {
        $tPosts = array();
        $id = $a["id"];
        switch ($type) {
            case 'twitter':
                $tPosts = topTweetEvents($id, $count);
                break;
            case 'facebook':
                $tPosts = fbEvents($id, $count);
                break;
            case 'instagram':
                $tPosts = igEvents($id, $count);
                break;
        }
        foreach ($tPosts as $key => &$p) {
            $p['username'] = $a['username'];
        }
        $posts = array_merge($posts, $tPosts);
    }
    usort($posts, "scoreSortSocial");
    return array_splice($posts, 0, $count);
    /*
    $rPosts = array();
    for ($i=0; $i < $count ; $i++)
    {
    	$rPosts[$i] = $posts[$i];
    }
    return $rPosts;
    */
}
Пример #2
0
function getMultipleEvents($locations, $type, $count = 10)
{
    $result = array();
    $accounts = json_decode(file_get_contents('config/accounts.json'), true);
    foreach ($locations as $key => $loc) {
        if (!isset($accounts['location'][$loc])) {
            continue;
        }
        $locAccounts = $accounts['location'][$loc]['accounts'];
        foreach ($locAccounts as $key => $act) {
            if ($act["type"] != $type) {
                continue;
            }
            $id = $act["id"];
            $temp = array();
            switch ($type) {
                case 'twitter':
                    $temp = topTweetEvents($id, $count);
                    break;
                case 'facebook':
                    $temp = fbEvents($id, $count);
                    break;
                case 'instagram':
                    $temp = igEvents($id, $count);
                    break;
            }
            $result = array_merge($result, $temp);
        }
    }
    usort($result, "scoreSort");
    $slice = array_slice($result, 0, $count);
    return $slice;
}