Beispiel #1
0
if (get_qaul_setting("twitter_search_term")) {
    // check for last message entry.
    // if there is a message not older than 60 minutes
    $type = 22;
    $last = MsgQuery::create()->filterByCreatedAt(array('min' => time() - 24 * 60 * 60))->filterByType($type)->orderByCreatedAt('desc')->findOne();
    // request messages for hash tag from twitter library
    // https://dev.twitter.com/docs/api/1.1/get/search/tweets
    $twitter_url = 'https://api.twitter.com/1.1/search/tweets.json';
    $twitter_requestMethod = 'GET';
    $twitter_getfield = '?q=' . get_qaul_setting("twitter_search_term");
    if ($last) {
        $twitter_getfield .= '&since_id=' . $last->getTwitterid();
    }
    // search only from this language
    if (get_qaul_setting("twitter_search_language")) {
        $twitter_getfield .= '&lang=' . get_qaul_setting("twitter_search_language");
    }
    // restrict number of results
    $twitter_getfield .= '&count=20';
    if (get_debug()) {
        echo "search/tweets twitter_getfield: {$twitter_getfield} \n";
    }
    $txt = $twitter->setGetfield($twitter_getfield)->buildOauth($twitter_url, $twitter_requestMethod)->performRequest();
    $data = json_decode($txt);
    if (get_debug()) {
        var_dump($data);
    }
    // put messages into data base and send them via qaul app
    if (isset($data->statuses)) {
        twitter_process_messages($data->statuses, $type);
    } elseif (isset($data->errors)) {
Beispiel #2
0
/**
 * create a short file link.
 * 
 * @retval link string
 */
function twitter_file_link($file)
{
    $link = "http://" . get_qaul_setting('domain') . "/f/" . $file->getId();
    return $link;
}
Beispiel #3
0
require_once '../qaulhub/helper_functions.php';
// check get variables
if (isset($_GET['id'])) {
    $id = $_GET['id'];
} else {
    $id = 0;
}
// pull messages from data base
if ($id) {
    $msgs = MsgQuery::create()->filterById(array('min' => $id + 1))->orderById('asc')->limit(10)->find();
} else {
    $msgs = MsgQuery::create()->orderById('desc')->limit(30)->find();
}
// send json to client
$first = true;
echo '{"name":"' . get_qaul_setting('name') . "\",\n";
echo "\"messages\":[\n";
foreach ($msgs as $msg) {
    if ($first) {
        $first = false;
    } else {
        echo ",\n";
    }
    echo "{";
    /*
    	echo '"id":' .$msg->getId() .',';
    	echo '"type":' .$msg->getType() .',';
    	echo '"name":"' .$msg->getName() .'",';
    	echo '"ip":"' .$msg->getIp() .'",';
    	echo '"msg":"' .protect_message($msg->getMsg()) .'",';
    	echo '"time":"' .$msg->getCreatedAt('Y-m-d H:i:s') .'",';