<?php

require_once dirname(__FILE__) . "/lib/TwitterSearch.php";
echo "Starting PHP  Worker101\n";
$payload = getPayload();
echo "We got following params\n";
print_r($payload);
echo "\nSearching Twitter\n";
$query = $payload->query;
$search = new TwitterSearch($query);
$results = $search->results();
print_r($results);
$file = 'output.txt';
echo "Writing to file";
file_put_contents($file, $results[0]->text);
$from_file = file_get_contents($file);
echo "Text from file\n";
print_r($from_file);
echo "\nWorker101 completed.";
Exemple #2
0
<?php

include_once 'inc/common.inc.php';
include_once 'core/TwitterAPI.php';
if ($_GET['pass'] == $vw_password) {
    // Search from Twitter
    $search = new TwitterSearch();
    $search->user_agent = $vw_useragent;
    $results = $search->results($vw_userid);
    // Select latest date from DB
    $tsql = "SELECT date FROM vws_words ORDER BY date DESC LIMIT 0, 1;";
    $tresult = $db->query($tsql);
    if ($row = $db->fetch_array($tresult)) {
        $last_item_timestamp = $row['date'];
    } else {
        $last_item_timestamp = 0;
    }
    foreach ($results as $key) {
        if (strpos($key->text, $vw_hashtag)) {
            // Get word from hashtag tweet
            $tweet = substr($key->text, 0, strrpos($key->text, '#'));
            $notation = array(',', '.', ',', '。');
            $tweet = str_replace($notation, ',', $tweet);
            $words = explode(',', $tweet);
            $words = array_map('trim', $words);
            $date = $key->created_at;
            $date = strtotime(substr($date, 0, 25));
            foreach ($words as $word) {
                $word = new query_Word($word);
                $dict = new query_qqDict();
                $d = $word->query($dict);