Beispiel #1
0
        $response["error"] = true;
        $response["message"] = "Failed to create task. Please try again";
    }
    echoRespnse(201, $response);
});
/**
 * Listing all tasks of particual user
 * method GET
 * url /tasks          
 */
$app->get('/tasks', 'authenticate', function () {
    global $user_id;
    $response = array();
    $db = new DbHandler();
    // fetching all user tasks
    $result = $db->getAllUserTasks($user_id);
    $response["error"] = false;
    $response["tasks"] = array();
    // looping through result and preparing tasks array
    while ($task = $result->fetch_assoc()) {
        $tmp = array();
        $tmp["id"] = $task["id"];
        $tmp["task"] = $task["task"];
        $tmp["status"] = $task["status"];
        $tmp["createdAt"] = $task["created_at"];
        array_push($response["tasks"], $tmp);
    }
    echoRespnse(200, $response);
});
/**
 * Listing single task of particual user
Beispiel #2
0
    } else {
        $response["error"] = true;
        $response["message"] = "Uploading failed. Please try again! {$userId}";
    }
    echoRespnse(200, $response);
});
/**
 * Listing all tasks of particual user
 * method GET
 * url /tasks          
 */
$app->get('/tasks', 'authenticate', function () {
    $response = array();
    $db = new DbHandler();
    // fetching all user tasks
    $result = $db->getAllUserTasks($_SESSION['user_id']);
    $response["error"] = false;
    $response["tasks"] = array();
    // looping through result and preparing tasks array
    while ($task = $result->fetch_assoc()) {
        $tmp = array();
        $tmp["id"] = $task["id"];
        $tmp["task"] = $task["task"];
        $tmp["status"] = $task["status"];
        $tmp["createdAt"] = $task["created_at"];
        array_push($response["tasks"], $tmp);
    }
    echoRespnse(200, $response);
});
/**
 * Listing single task of particual user