示例#1
0
             $order = array();
             $order['client'] = $user['uid'];
             $order['snack_2'] = 1;
             new_order($order);
             // get the new user balance
             $user = get_user_by_uid($user['uid']);
             send_headers();
             $response = array("version" => $version, "response" => "OK", "uid" => $user['uid'], "balance" => floatval($user['balance']));
             echo json_encode($response);
         } else {
             forbidden();
         }
     }
 } elseif ('coffees' == $_GET['uri']) {
     send_headers();
     $today = get_coffees_today();
     $month = get_coffees_this_month();
     $all = get_coffees();
     $coffees = array("today" => intval($today), "month" => intval($month), "all" => intval($all));
     $response = array("version" => $version, "response" => $coffees);
     echo json_encode($response);
 } elseif ('permissions' == $_GET['uri'] && isset($_GET['uid']) && isset($_GET['id'])) {
     send_headers();
     $permission = get_permission($_GET['uid'], $_GET['id']);
     echo json_encode($permission);
 } elseif ('permissions' == $_GET['uri'] && isset($_GET['id'])) {
     send_headers();
     $permissions = get_reader_permissions($_GET['id']);
     echo json_encode($permissions);
 } elseif ('orders' == $_GET['uri'] && isset($_GET['id'])) {
     send_headers();
示例#2
0
function grid_json_action()
{
    header('Content-type: application/json; charset=utf-8');
    header("Cache-Control: no-cache, must-revalidate");
    $coffees_today = get_coffees_today();
    $money_today = get_money_spent_today();
    $filename = "laboite.json";
    if (!file_exists($filename) || time() - filemtime($filename) > 60) {
        copy("http://api.laboite.cc/61c119ce.json", $filename);
    }
    $json_string = file_get_contents($filename);
    $parsed_json = json_decode($json_string);
    $bus = $parsed_json->{'bus'};
    $bikes = $parsed_json->{'bikes'};
    $temperature = $parsed_json->{'weather'}->{'today'}->{'temperature'};
    $icon = $parsed_json->{'weather'}->{'today'}->{'icon'};
    $message = get_last_message();
    $people = get_people_today();
    $json = array("coffees" => $coffees_today, "money" => $money_today, "message" => $message, "bus" => $bus, "bikes" => $bikes, "people" => $people, "icon" => $icon, "temperature" => $temperature);
    echo json_encode($json);
}