Example #1
0
File: main.php Project: MxAR/SGP
<?php

require_once 'TwitterAPIExchange.php';
require_once 'hashtagprediction.php';
const AVGFOLLOW = 100;
$ini = parse_ini_file('default.ini', false);
$apiSettings = array('oauth_access_token' => $ini['oauth_access_token'], 'oauth_access_token_secret' => $ini['oauth_access_token_secret'], 'consumer_key' => $ini['consumer_key'], 'consumer_secret' => $ini['consumer_secret']);
$inputDbSettings = array('db_host' => $ini['db_host'], 'db_name' => $ini['db_name'], 'db_user' => $ini['db_user'], 'db_passwd' => $ini['db_passwd']);
$fishy_str = $_POST['fishy_str'];
$qstring = encode($fishy_str, $inputDbSettings);
$since = timespan($fishy_str);
$result = api_req($qstring, $since, $apiSettings);
$retweet_count = analyse_grades($result['statuses']);
echo json_encode(array($retweet_count / AVGFOLLOW, $retweet_count));
function api_req($qstring, $since, $apiSettings)
{
    $url = 'https://api.twitter.com/1.1/search/tweets.json';
    $getfield = '?q=' . $qstring . '+since:' . $since . '&lang=en&result_type=recent&count=50';
    $requestMethod = 'GET';
    $twitter = new TwitterAPIExchange($apiSettings);
    return json_decode($twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(), true);
}
function analyse_grades($statuses)
{
    // $favorite_count = 0;
    $retweet_count = 0;
    $j = 1;
    foreach ($statuses as $i) {
        // $favorite_count += $i['favorites_count'];
        $retweet_count += $i['retweet_count'];
        $j++;
Example #2
0
function getfiles()
{
    global $master_key, $root_id, $inbox_id, $trashbin_id;
    $files = api_req(array('a' => 'f', 'c' => 1));
    foreach ($files->f as $file) {
        if ($file->t == 0 || $file->t == 1) {
            $key = substr($file->k, strpos($file->k, ':') + 1);
            $key = decrypt_key(base64_to_a32($key), $master_key);
            if ($file->t == 0) {
                $k = array($key[0] ^ $key[4], $key[1] ^ $key[5], $key[2] ^ $key[6], $key[3] ^ $key[7]);
                $iv = array_merge(array_slice($key, 4, 2), array(0, 0));
                $meta_mac = array_slice($key, 6, 2);
            } else {
                $k = $key;
            }
            $attributes = base64urldecode($file->a);
            $attributes = dec_attr($attributes, $k);
            if ($file->h == 'gldU3Tab') {
                downloadfile($file, $attributes, $k, $iv, $meta_mac);
            }
        } else {
            if ($file->t == 2) {
                $root_id = $file->k;
            } else {
                if ($file->t == 3) {
                    $inbox_id = $file->k;
                } else {
                    if ($file->t == 4) {
                        $trashbin_id = $file->k;
                    }
                }
            }
        }
    }
}