if ($mode == 'create') { //create object model $model->insert($_POST)->save(); echo 'Object created successfully.'; } else { if ($mode == 'update') { //update object model $model->update($_POST)->save(); echo 'Object updated successfully.'; } } } return; } if (getPostNull($uid, 'uid')) { echo $model->getJson($uid); return; } if (getPost($rid, 'delete')) { $model->remove($rid); echo '0'; return; } $this_file = basename(__FILE__); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8">
require_once '../nl-init.php'; require_once '../class/nl-user-class.php'; require_once '../class/nl-auth-class.php'; require_once 'api_headers.php'; try { if (is_get()) { $userID = _get('userID', 0); if ($userID <= 0) { throw new Exception("user does not exists", -1); } $auth = Auth::getInstance(); if ($auth->getUserID() != $userID) { throw new Exception("unauthorized", -1); } $user = new User($userID); echo $user->getJson(); } else { if (is_post()) { $fields = array(); $fbID = _post("fbID", ""); $user = new User(); $auth = Auth::getInstance(); if ($fbID != "") { $fbName = _post("fbName", ""); $fbEmail = _post("fbEmail", ""); if ($fbName == "" || $fbEmail == "") { throw new Exception("incorrect parameters", -1); } $fields = array("fbID" => $fbID, "fbName" => $fbName, "fbEmail" => $fbEmail); $user->createUser($fields); $auth->fbLogin($fbEmail, $fbID, $fbName);