Esempio n. 1
0
include 'src/authorization.php';
echo "<br>";
//SaveToSQL if data_in_db is false
if (!isset($_SESSION['data_in_db']) || $_SESSION['data_in_db'] == false) {
    $_SESSION['data_in_db'] = true;
    // Initialize $next_max_id and $cursor variable
    $next_max_id = null;
    $cursor = null;
    echo "The if statement is true, now paging through tweets. <br>";
    // While there are still tweets, run saveToSQL
    while (true) {
        echo "The tweet while statement is true <br>";
        // Preserve previously recieved cursor
        $next_max_id_temp = $next_max_id;
        // Run saveToSQL and store return array into $return_array
        $next_max_id = saveToSQL($connection, $next_max_id_temp);
        $next_max_id_str = (string) $next_max_id;
        echo "The next_max_id is " . $next_max_id_str . "<br>";
        if ($next_max_id == $next_max_id_temp || $next_max_id == null) {
            break;
        }
    }
    echo "Saving trends now <br>";
    saveTrendsToSQL($connection);
    echo "Saving DMs now <br>";
    savedirectMessagesToSQL($connection);
    echo "Direct messages saved, now paging through friends. <br>";
    $_SESSION["rank_counter"] = 0;
    while (true) {
        echo "The friends while statement is true <br>";
        $cursor_temp = $cursor;
Esempio n. 2
0
//					/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
//					$settings = array(
//									  'oauth_access_token' => $_SESSION['oauth_access_token'],
//									  'oauth_access_token_secret' => $_SESSION['oauth_access_token_secret'],
//									  'consumer_key' => CONSUMER_KEY,
//									  'consumer_secret' => CONSUMER_SECRET
//									  );
//
//					/** Perform a GET request and echo the response **/
//					$url = 'https://api.twitter.com/1.1/statuses/home_timeline.json';
//					$requestMethod = 'GET';
//					$twitter = new TwitterAPIExchange($settings);
//					$jsonTweets = $twitter->buildOauth($url, $requestMethod)
//								->performRequest();
//$jsonTweets = $connection->get("statuses/home_timeline", array("count" => 200, "include_entities" => true));
saveToSQL($connection, $user);
//                    $jsonTweets = getData($connection);
/** Process the response (JSON format) using json_decode: http://docs.php.net/json_decode **/
$response = json_decode($jsonTweets, true);
/** Go through every tweet and print out line by line -- will ideally need some pleasant wrapping with bootstrap -- maybe add IDs to process instead
			 Example of the kind of information that can be returned here: https://dev.twitter.com/rest/reference/get/statuses/home_timeline **/
echo "<br>";
//________________________________________________________EVERYTHING BELOW THIS LINE IS THE ALGORITHM_______________________________________________________________
$user_ip = getenv('REMOTE_ADDR');
$geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip={$user_ip}"));
$country = $geo["geoplugin_countryName"];
$city = $geo["geoplugin_city"];
$place = $connection->get("geo/search", array("query", $city));
if ($city == "") {
    $place = 23424977;
}