예제 #1
0
파일: api.php 프로젝트: andrelotto/Cosmo
     break;
     ##################################################
     #                    Users                       #
     ##################################################
 ##################################################
 #                    Users                       #
 ##################################################
 case 'users':
     switch ($method) {
         case 'GET':
             if (count($segments) > 1 && $segments[1]) {
                 $response = $Cosmo->usersRead($segments[1]);
             } else {
                 if ($_GET['username'] && $_GET['password']) {
                     // Login
                     $response = $Cosmo->userLogin($_GET['username'], $_GET['password']);
                 } else {
                     if ($_GET['keyword']) {
                         // Get list of users starting with a keyword
                         $response = $Cosmo->usersRead(NULL, $_GET['keyword']);
                     } else {
                         // Get a list of all users
                         $response = $Cosmo->usersRead();
                     }
                 }
             }
             break;
         case 'POST':
             $username = isset($_POST['username']) ? $_POST['username'] : '';
             $email = isset($_POST['email']) ? $_POST['email'] : '';
             $password = isset($_POST['password']) ? $_POST['password'] : '';