Example #1
0
    $f = 'politician';
    $section = $f;
}
switch ($f) {
    case 'timeline':
        $section = 'timeline';
        if (!empty($nid) && is_numeric($nid)) {
        } else {
            $nid = null;
        }
        // require api here
        require_once 'api/api.inc';
        $page = !empty($_GET['p']) ? $_GET['p'] : 1;
        if (is_numeric($page) || $page === 'all') {
            require_once 'api/timeline.inc';
            print get_timeline();
            exit;
        }
        break;
    default:
        $section = $f;
        if (!empty($nid) && is_numeric($nid)) {
        } else {
            $nid = null;
        }
        // require api here
        require_once 'api/api.inc';
        if (file_exists($f . '.inc')) {
            include_once $f . '.inc';
            exit;
        }
Example #2
0
mysql_set_charset('utf-8');
$db_selected = mysql_select_db(TweetDB, $link);
if (!$db_selected) {
    die('no database');
}
$sql = sprintf("DELETE FROM %s", $user_id);
$result = mysql_query($sql);
if (!$db_selected) {
    die('no delete');
}
$close = mysql_close($link);
if (!$db_selected) {
    die('no close');
}
$tw = get_tweet();
$req = get_timeline($tw);
?>
  		  		var id_count = <?php 
echo json_encode(count($req) - 1);
?>
;
		  		var user_id = <?php 
echo json_encode($user_id);
?>
;
				var id = 0;
				<?php 
foreach ($req as $val) {
    ?>
					var val = <?php 
    echo json_encode($val, true);
Example #3
0
function get_timeline($user_id, $type, $max_id = null)
{
    print "doing {$user_id}\n";
    global $twitter_keys, $current_key, $ratefree, $looped, $bin_name, $dbh, $tweetQueue;
    $ratefree--;
    if ($ratefree < 1 || $ratefree % 10 == 0) {
        $keyinfo = getRESTKey($current_key, 'statuses', 'user_timeline');
        $current_key = $keyinfo['key'];
        $ratefree = $keyinfo['remaining'];
    }
    $tmhOAuth = new tmhOAuth(array('consumer_key' => $twitter_keys[$current_key]['twitter_consumer_key'], 'consumer_secret' => $twitter_keys[$current_key]['twitter_consumer_secret'], 'token' => $twitter_keys[$current_key]['twitter_user_token'], 'secret' => $twitter_keys[$current_key]['twitter_user_secret']));
    $params = array('count' => 200, 'trim_user' => false, 'exclude_replies' => false, 'contributor_details' => true, 'include_rts' => 1);
    if ($type == "user_id") {
        $params['user_id'] = $user_id;
    } else {
        $params['screen_name'] = $user_id;
    }
    if (isset($max_id)) {
        $params['max_id'] = $max_id;
    }
    $tmhOAuth->user_request(array('method' => 'GET', 'url' => $tmhOAuth->url('1.1/statuses/user_timeline'), 'params' => $params));
    //var_export($params); print "\n";
    if ($tmhOAuth->response['code'] == 200) {
        $tweets = json_decode($tmhOAuth->response['response'], true);
        // store in db
        $tweet_ids = array();
        foreach ($tweets as $tweet) {
            $t = new Tweet();
            $t->fromJSON($tweet);
            $tweet_ids[] = $t->id;
            if (!$t->isInBin($bin_name)) {
                $tweetQueue->push($t, $bin_name);
                print ".";
                if ($tweetQueue->length() > 100) {
                    $tweetQueue->insertDB();
                }
            }
        }
        if (!empty($tweet_ids)) {
            print "\n";
            if (count($tweet_ids) <= 1) {
                print "no more tweets found\n\n";
                return false;
            }
            $max_id = min($tweet_ids);
            print "max id: " . $max_id . "\n";
        } else {
            print "0 tweets found\n\n";
            return false;
        }
        sleep(1);
        get_timeline($user_id, $type, $max_id);
    } else {
        $error_code = json_decode($tmhOAuth->response['response'])->errors[0]->code;
        if ($error_code == 130) {
            print "Twitter is over capacity, sleeping 5 seconds before retry\n";
            sleep(5);
            get_timeline($user_id, $type, $max_id);
        } elseif ($error_code == 88) {
            print "API key rate limit exceeded, sleeping 60 seconds before retry\n";
            sleep(60);
            get_timeline($user_id, $type, $max_id);
        } else {
            echo "\nAPI error: " . $tmhOAuth->response['response'] . "\n";
        }
    }
}
Example #4
0
<?php

session_start();
include "../config.php";
include "../functions.php";
include "../private_functions.php";
if (isset($_SESSION['auth']) && $_SESSION['auth'] == 1) {
    $dbh = db_connect($MY_HOST, $MY_DB_PORT, $MY_DB, $DB_USER, $DB_PW);
    $num = 10;
    $start = PHP_INT_MAX;
    if (isset($_GET['count']) && is_numeric($_GET['count'])) {
        $num = $_GET['count'];
    }
    if (isset($_GET['start_time'])) {
        $start = $_GET['start_time'];
    }
    $res = get_timeline($dbh, $_SESSION['user'], $num, $start);
    close_db_connection($dbh);
    echo json_encode($res);
} else {
    echo json_encode(array("status" => -1));
}
Example #5
0
if (isset($_GET['start'])) {
    $timeline = get_timeline($dbh, $_SESSION['user'], 15, $_GET['start']);
} else {
    $timeline = get_timeline($dbh, $_SESSION['user'], 15);
}
$last_time = -1;
if ($timeline['status'] == 1) {
    $posts = $timeline['posts'];
    for ($i = 0; $i < count($posts); $i++) {
        error_log($posts[$i]['time']);
        html_post($dbh, $posts[$i]);
        $num_output++;
        $last_time = $posts[$i]['time'];
    }
}
if ($num_output == 0) {
    echo "<div class='row' style='font-size: 21px; padding-left: 30px; padding-right: 30px; padding-top: 5px;'> There appears to be no posts here.</div>";
} else {
    if ($last_time > 0) {
        $timeline = get_timeline($dbh, $_SESSION['user'], 15, $last_time);
        if ($timeline['status'] == 1) {
            if (count($timeline['posts']) > 0) {
                echo "<div class='row' style='text-align: center; font-size: 21px; padding-left: 30px; padding-right: 30px; margin-top: 35px;'> <a href='timeline.php?start=" . $last_time . "'>More</a></div>";
            }
        }
    }
}
?>
	</body>
</html>
<?php

require_once "libs/get_content.php";
require_once "libs/Browser.class.php";
$timeline = get_timeline("data/timeline.json");
$date = $timeline['date'];
$chapter = $timeline['chapter'];
$tags = $timeline['tag'];
$browser = new Browser();
if ($browser->getBrowser() == 'Internet Explorer' && preg_match("/^[6-8]{1}/i", $browser->getVersion())) {
    include "ie8.html";
    exit;
}
$permalink = 'http://www.taogi.net/special/sewolho/background/';
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
	<meta name="viewport" content="user-scalable=no,width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
	<title>세월호는 왜.</title>
	<meta name="keywords" content="세월호,타임라인,참사,구조적 원인" />
	<meta name="author" content="진보네트워크센터 + 정보공개센터" />
	<meta name="twitter:card" content="summary_large_image" />
	<meta name="twitter:site" content="@jinbonet" />
	<meta name="twitter:creator" content="@jinbonet" />
	<meta property="og:title" content="세월호는 왜." />
	<meta property="og:site_name" content="Taogi Special Project: 세월호" />
	<meta property="og:url" content="<?php 
print $permalink;
 /**
  * Quick method to return 20 most recent mentions
  *
  * @access public
  * @since 2.0
  * @return object
  */
 public function get_mentions()
 {
     return get_timeline('mentions');
 }