Exemple #1
0
function poll()
{
    global $TWEET_SEARCH;
    // global!
    $last_tweet_ts_received = $_GET["last_tweet_ts_rcvd"];
    // pull latest from database
    $db = new database(DB_HOST, DB_USER, DB_PASS);
    $last_updated = $db->getLatestTweetTimestamp();
    if ($last_tweet_ts_received >= $last_updated) {
        $tweet_array = pollTwitter($TWEET_SEARCH, TWEET_MAX_DISPLAY);
        $db->pushTweets($tweet_array);
    }
    if ($last_updated != $last_tweet_ts_received) {
        $tweet = $db->getTweets(1);
        echo json_encode($tweet);
    }
}
Exemple #2
0
<?php

include_once 'functions.php';
// <!-- TWIG SETUP -->
require_once './lib/Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('./tpl/');
$twig = new Twig_Environment($loader, array('cache' => './cache/', 'auto_reload' => true));
$template = $twig->loadTemplate('main.html');
// <! -- END TWIG -->
// <!-- MAIN -->
$db = new database(DB_HOST, DB_USER, DB_PASS);
// Poll Twitter, Push to Database if too much time has elapsed since last push.
$last_updated = $db->getLatestTweetTimestamp();
// in epoch time
$time = time();
// grab time now (epoch)
if ($time - $last_updated > TWEET_POLL) {
    $tweet_array = pollTwitter($TWEET_SEARCH, TWEET_MAX_DISPLAY);
    $db->pushTweets($tweet_array);
}
$vars["page"] = "index";
// Pull set of Tweets from DB to Display.
$vars["tweets"] = $db->getTweets();
$template->display($vars);
Exemple #3
0
<?php

chdir("..");
// change working directory
include_once "config.php";
include_once "classes/database.php";
include_once "classes/tweet.php";
include_once "functions.php";
echo "testing functions.php";
$arr = array("lulz", "XD");
$tweets = pollTwitter($arr, 10);
echo "<br>structure: <br><br><br>";
print_r($tweets);
echo "<br><br><br>var dump: <br>";
var_dump($tweets);