Exemplo n.º 1
0
function main()
{
    $acts = loadAccounts();
    $fb = $acts['facebook'];
    $ig = $acts['instagram'];
    $twit = $acts['twitter'];
    print "<pre>FB:\n";
    foreach ($fb as $key => $id) {
        $stats = fbStats($id);
        if (isset($stats)) {
            saveStats($stats, $id, "facebook");
        }
    }
    print "\nTwit:\n";
    foreach ($twit as $key => $id) {
        $stats = twitStats($id);
        if (isset($stats)) {
            saveStats($stats, $id, "twitter");
        }
    }
    print "\nIG:\n";
    foreach ($ig as $key => $id) {
        $stats = igStats($id);
        if (isset($stats)) {
            saveStats($stats, $id, "instagram");
        }
    }
    print "</pre>";
}
Exemplo n.º 2
0
 } else {
     if ($_POST['requested'] == "saveStats") {
         $exeID = $_POST['exeID'];
         $array = $_POST['array'];
         if (is_array($array)) {
             $arrayString = implode(",", $array);
         }
         $isRecommended = $_POST['isRecommended'];
         $length = $_POST['length'];
         $algorithm = $_POST['algorithm'];
         $order = $_POST['order'];
         $target = $_POST['target'];
         $typeOfData = $_POST['typeOfData'];
         $steps = $_POST['steps'];
         $time = $_POST['time'];
         $retVal = saveStats($exeID, $arrayString, $isRecommended, $length, $algorithm, $order, $target, $typeOfData, $steps, $time);
         print json_encode($retVal);
     } else {
         if ($_POST['requested'] == "getStatsRecommended") {
             if (checkSession()) {
                 $id = $_SESSION['user_id'];
             } else {
                 $id = 12;
             }
             $type = $_POST['type'];
             $retVal = getStatsProcessed($id, 0, $type);
             print json_encode($retVal);
         } else {
             if ($_POST['requested'] == "getStats") {
                 $algorithm = $_POST['algorithm'];
                 $retVal = getStatsProcessed(0, $algorithm, 0);
Exemplo n.º 3
0
require_once 'Slim/Slim.php';
require_once 'stats.php';
// Configure
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
/*
 * Get Stats for User ID
 */
$app->get('/stats/:id', function ($id) {
    $stats = getStats($id);
    echo json_encode($stats);
});
/*
 * Get Stats for User ID
 */
$app->post('/stats/:id', function ($id) {
    global $app;
    $stats = getStats($id);
    $key = $app->request->post('result');
    $stats[$key]++;
    saveStats($id, $stats);
    echo json_encode($stats);
});
/*
 * Home
 */
$app->get('/', function () use($app) {
    $app->render('home.html');
});
$app->run();