当前位置: 首页>>代码示例>>PHP>>正文


PHP verifyRequiredParams函数代码示例

本文整理汇总了PHP中verifyRequiredParams函数的典型用法代码示例。如果您正苦于以下问题:PHP verifyRequiredParams函数的具体用法?PHP verifyRequiredParams怎么用?PHP verifyRequiredParams使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了verifyRequiredParams函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateContact

function updateContact($id)
{
    $request = Slim\Slim::getInstance()->request();
    $id = intval($id);
    verifyRequiredParams(array(CONTACTS::NAME, CONTACTS::NUMBER));
    $name = trim($request->put(CONTACTS::NAME));
    $email = strtolower(trim($request->put(CONTACTS::EMAIL)));
    $number = $request->put(CONTACTS::NUMBER);
    $is_favourite = $request->put(CONTACTS::IS_FAVOURITE);
    $is_favourite = $is_favourite === 'true' ? true : false;
    $contact = array(CONTACTS::NAME => $name, CONTACTS::EMAIL => $email, CONTACTS::NUMBER => $number, CONTACTS::IS_FAVOURITE => $is_favourite);
    $contact = removeEmptyFields($contact);
    $query = new QueryHandler();
    $response = $query->updateContact($id, $contact);
    echoRespnse($response);
}
开发者ID:saiful15,项目名称:REST-in-SlimFramework,代码行数:16,代码来源:index.php

示例2: echoRespnse

    } else {
        if ($res == ISSUE_LOG_FAILED) {
            $response["error"] = true;
            $response["message"] = 'Oops! We are unable to log an issue for this spot.';
        } else {
            if ($res == ISSUE_FOR_SPOT_ALREADY_EXISTS) {
                $response["error"] = true;
                $response["message"] = 'An issue has already been logged for this spot';
            }
        }
    }
    // echo json response
    echoRespnse(201, $response);
});
$app->post('/addSpotRequest', function () use($app) {
    verifyRequiredParams(array('userId', 'spotName', 'regionName', 'country'));
    $response = array();
    // reading post params
    //$email = $app->request()->post('email');
    //$user_id = $app->request()->post('userId');
    $spotName = $app->request()->post('spotName');
    $regionName = $app->request()->post('regionName');
    $country = $app->request()->post('country');
    //global $user_id;
    $db = new DbHandler();
    $user = $db->getUserById($user_id);
    global $EmailAdmin;
    global $EmailFrom;
    $EmailTo = $EmailAdmin;
    $Subject = "A user has submitted a request to Add a Spot";
    // prepare email body text
开发者ID:AshKetchumza,项目名称:Wavey,代码行数:31,代码来源:index.php

示例3: echoRespnse

        echoRespnse(201, $response);
    } else {
        $response["error"] = true;
        $response["message"] = "Failed to create contact. Please try again";
        echoRespnse(200, $response);
    }
});
/**
 * Updating existing contact
 * method PUT
 * params contact, status
 * url - /contacts/:id
 */
$app->put('/contacts/:id', 'authenticate', function ($contact_id) use($app) {
    // check for required params
    verifyRequiredParams(array('contact', 'status'));
    global $user_id;
    $contact = $app->request->put('contact');
    $status = $app->request->put('status');
    $db = new DbHandler();
    $response = array();
    // updating task
    $result = $db->updateTask($user_id, $contact_id, $contact, $status);
    if ($result) {
        // contact updated successfully
        $response["error"] = false;
        $response["message"] = "Contact updated successfully";
    } else {
        // contact failed to update
        $response["error"] = true;
        $response["message"] = "Contact failed to update. Please try again!";
开发者ID:stephaneGJ,项目名称:my_contacts_api,代码行数:31,代码来源:index.php

示例4: echoRespnse

        $response["createdAt"] = $result["created_at"];
        echoRespnse(200, $response);
    } else {
        $response["error"] = true;
        $response["message"] = "The requested resource doesn't exists";
        echoRespnse(404, $response);
    }
});
/**
 * Adding sample data points to Journeys data table
 * method PUT
 * url - //:id
 */
$app->post('/journey/:id', 'authenticate', function ($journey_id) use($app) {
    // check for required params
    verifyRequiredParams(array('x_gps', 'y_gps', 'x_acl', 'y_acl', 'z_acl', 'timestamp', 'sample_no'));
    // reading post params
    $x_gps = $app->request->post('x_gps');
    $y_gps = $app->request->post('y_gps');
    $x_acl = $app->request->post('x_acl');
    $y_acl = $app->request->post('y_acl');
    $z_acl = $app->request->post('z_acl');
    $timestamp = $app->request->post('timestamp');
    $sample_no = $app->request->post('sample_no');
    $response = array();
    global $user_id;
    // Admin is user 1. Special privedges
    // but cant post sample points
    if ($user_id == 1) {
        $response["error"] = false;
        $response["message"] = "Admin can only view journeys";
开发者ID:blahblahQ,项目名称:Keep-on-Track-github,代码行数:31,代码来源:index.php

示例5: echoResponse

            $_SESSION['email'] = $email;
            $_SESSION['name'] = $user['name'];
        } else {
            $response['status'] = "error";
            $response['message'] = 'Login failed. Incorrect credentials';
        }
    } else {
        $response['status'] = "error";
        $response['message'] = 'No such user is registered';
    }
    echoResponse(200, $response);
});
$app->post('/signUp', function () use($app) {
    $response = array();
    $r = json_decode($app->request->getBody());
    verifyRequiredParams(array('email', 'name', 'password'), $r->user);
    require_once 'passwordHash.php';
    $db = new DbHandler();
    $phone = $r->user->phone;
    $name = $r->user->name;
    $email = $r->user->email;
    $address = $r->user->address;
    $password = $r->user->password;
    $isUserExists = $db->getOneRecord("select 1 from users where phone='{$phone}' or email='{$email}'");
    if (!$isUserExists) {
        $r->user->password = passwordHash::hash($password);
        $tabble_name = "users";
        $column_names = array('phone', 'name', 'email', 'password', 'city', 'address');
        $result = $db->insertIntoTable($r->user, $column_names, $tabble_name);
        if ($result != NULL) {
            $response["status"] = "success";
开发者ID:anankitpatil,项目名称:angular,代码行数:31,代码来源:authentication.php

示例6: json_encode

            $response["code"] = $status;
            $response["message"] = "Contingent {$contingent->getId()} updated successfully.";
        } else {
            $status = 200;
            $response["code"] = $status;
            $response["error"] = 1;
            $response["error_message"] = "Some error occured while updating contingent {$contingent->getId()}.";
        }
    } else {
        $response["error"] = 1;
        $response["error_message"] = "Invalid ID,Expecting numeric ID";
    }
    print json_encode($response);
});
$app->put('/event/:id', function ($id) use($app, $eventMapper) {
    verifyRequiredParams(array('id', 'logo'));
    $event = new Event();
    $event->setId($id);
    $event->setName($app->request()->put('name'));
    $event->setDetails($app->request()->put('details'));
    $event->setSlogan($app->request()->put('slogan'));
    $event->setCategory($app->request()->put('type'));
    $event->setRules($app->request()->put('rules'));
    $event->setStartDate($app->request()->put('start_date'));
    $event->setEndDate($app->request()->put('end_date'));
    $event->setStartTime($app->request()->put('start_time'));
    $event->setEndTime($app->request()->put('end_time'));
    $event->setGroupSize($app->request()->put('group_size'));
    $event->setLogo($app->request()->put('logo'));
    # --Getting the put vars and typecasting to int. Blehhh. Can't help, its PHP xD
    $feeHome = $app->request()->put('fee_home');
开发者ID:bedekarsarvesh,项目名称:Udaan2016,代码行数:31,代码来源:index.php

示例7: echoRespnse

        if ($res == USER_CREATE_FAILED) {
            $response["error"] = true;
            $response["message"] = "Oops! An error occurred while registereing";
            echoRespnse(200, $response);
        } else {
            if ($res == USER_ALREADY_EXISTED) {
                $response["error"] = true;
                $response["message"] = "Sorry, this email already existed";
                echoRespnse(200, $response);
            }
        }
    }
});
$app->post('/addproject', function () use($app) {
    // check for required params
    verifyRequiredParams(array('name', 'start_date', 'end_date', 'description', 'team_lead', 'target_audience', 'estimated_funds'));
    $response = array();
    $name = $app->request->post('name');
    $start_date = $app->request->post('start_date');
    $end_date = $app->request->post('end_date');
    $description = $app->request->post('description');
    $team_lead = $app->request->post('team_lead');
    $target_audience = $app->request->post('target_audience');
    $estimated_funds = $app->request->post('estimated_funds');
    $db = new DbHandler();
    $res = $db->addProject($name, $start_date, $end_date, $description, $team_lead, $target_audience, $estimated_funds);
    if ($res != PROJECT_CREATE_FAILED) {
        $response["error"] = false;
        $response["message"] = "project successfully registered with id" + $res;
        echoRespnse(201, $response);
    } else {
开发者ID:karimyasser91,项目名称:EKTechnologies,代码行数:31,代码来源:index.php

示例8: echoRespnse

        }
    } else {
        // user credentials are wrong
        $response['error'] = true;
        $response['message'] = 'Login failed. Incorrect credentials';
    }
    echoRespnse(200, $response);
});
/**
 * Listing single task of list mk
 * method GET
 * url /listmk
 * Will return 404 if the task doesn't belongs to user
 */
$app->get('/listmk/:id', function ($id) {
    verifyRequiredParams(array('id'));
    // reading post params
    //    $id = $app->request()->get('id');
    $response = array();
    $db = new DbHandler();
    // fetch task
    $result = $db->getMK($id);
    // 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["listmk"], $tmp);
    }
开发者ID:nandawperdana,项目名称:mobilelearning,代码行数:31,代码来源:index.php

示例9: echoResponse

            break;
        case USER_CREATED_SUCCESSFULLY:
            $response["error"] = false;
            $response["message"] = "You are successfully registered";
            echoResponse(201, $response);
            break;
        default:
            $response["error"] = true;
            $response["message"] = "An error occurred while registering";
            echoResponse(200, $response);
            break;
    }
});
$app->post('/login', function () use($app) {
    // check for required params
    verifyRequiredParams(array('email', 'password'));
    // reading post params
    $body = json_decode($app->request->getBody(), true);
    $email = $body['email'];
    $password = $body['password'];
    $response = array();
    $db = new DbHandler();
    // check for correct email and password
    if ($db->checkLogin($email, $password)) {
        // get the user by email
        $response = $db->getUserByEmail($email);
        if ($response != NULL) {
            $response["error"] = false;
        } else {
            // unknown error occurred
            $response['error'] = true;
开发者ID:Breedr,项目名称:Piazza,代码行数:31,代码来源:index.php

示例10: function

*   error:  false
*   message: "Benutzer wurde erfolgreich hinzugefügt"
* }
* @apiSuccessExample Error (Beispiel):
 *     {
 *       error: true
 *       message: 'Fehler! Benutzer/Kartensatz konnte nicht gefunden werden.'
 *     }
 *
 * @apiSuccessExample CURL Beispiel:
  *       curl  -H "Authorization: ce0783ccae32b2eddf9d49a6c8592dfb" -X POST -d "username=vogt" -d "persmission=1" http://karta.dima23.de/api/index.php/permission/12
*/
$app->post('/permission/:cardsetid', 'authenticate', function ($cardsetid) use($app) {
    $response = array();
    verifyRequiredParams(array('username'));
    verifyRequiredParams(array('permission'));
    $username = $app->request->post('username');
    $permission = $app->request->post('permission');
    $db = new DBHandler();
    $userid = $db->getUser($username);
    $result = $db->assignUserCardset($userid['userid'], $cardsetid, $permission);
    if ($result != NULL) {
        $response["error"] = false;
        $response['message'] = "Benutzer wurde erfolgreich hinzugefügt";
        echoRespnse(200, $response);
    } else {
        $response["error"] = true;
        $response["message"] = "Fehler! Benutzer/Kartensatz konnte nicht gefunden werden." . $result;
        echoRespnse(201, $response);
    }
});
开发者ID:dvogt23,项目名称:KartApp-www,代码行数:31,代码来源:index.php

示例11: echoRespnse

                $response['error'] = FALSE;
                $response['message'] = "successfully Liked";
            } else {
                $response['error'] = TRUE;
                $response['message'] = "Unsuccessful like addition";
            }
        } else {
            $response['error'] = TRUE;
            $response['message'] = "No previous value to dislike or bad value";
        }
    }
    echoRespnse(200, $response);
});
/* add/update rating to tv_series */
$app->post('/collection/:id/rating', 'authenticate', function ($id_tv_series) use($app) {
    verifyRequiredParams(array('rating_value'));
    $rating_value = $app->request()->post('rating_value');
    global $user_id;
    $response = [];
    $db = new DbHandler();
    $rating_id = $db->isRatingAvailable($id_tv_series, $user_id);
    if ($rating_value <= 5 && $rating_value >= 0) {
        if ($rating_id) {
            if ($db->updateRating($rating_id["id_rating"], $rating_value)) {
                $response['error'] = FALSE;
                $response['message'] = "successfully updated rating";
            } else {
                $response['error'] = TRUE;
                $response['message'] = "Updating rating unsuccessful";
            }
        } else {
开发者ID:adib2149,项目名称:PHP_SLIM_RESTfulAPI_tv-series-manager,代码行数:31,代码来源:index.php

示例12: echoResponse

        } else {
            $response['status'] = "info";
            $response['message'] = 'No fue posible agregar los datos';
        }
    } else {
        $response['status'] = "info";
        $response['message'] = 'El usuario ya existe';
    }
    echoResponse(200, $response);
});
//
$app->post('/userU', 'sessionAlive', function () use($app) {
    // Recupera los datos de la forma
    //
    $r = json_decode($app->request->getBody());
    verifyRequiredParams(array('id', 'nombre', 'nombres', 'apellidos', 'idrol', 'idorganizacion', 'estado', 'email', 'cargo'), $r->user);
    //
    $id = $r->user->id;
    $nombre = $r->user->nombre;
    $nombres = $r->user->nombres;
    $apellidos = $r->user->apellidos;
    $idrol = $r->user->idrol;
    $idorganizacion = $r->user->idorganizacion;
    $estado = $r->user->estado;
    $email = $r->user->email;
    $cargo = $r->user->cargo;
    $response = array();
    //
    //
    // Ejemplo de uso de un insert:
    //
开发者ID:albizures,项目名称:anadie,代码行数:31,代码来源:usuarios.php

示例13: function

<?php

$app->get('/event/external/:eventId', function ($eventId) use($app) {
    // check for required params
    verifyRequiredParams(array('source'));
    $source = $app->request->params('source');
    $model = new findEventModel($eventId, $source, $app);
    $json_response = $model->getJsonWithChecksum();
    $app->contentType('application/json');
    echo $json_response;
});
开发者ID:AdventureKing,项目名称:EventFeast,代码行数:11,代码来源:event.php

示例14: function

<?php

/**
 * Creating new call in db
 * method POST
 * params - name
 * url - /calls/
 */
$app->post('/calls', 'authenticate', function () use($app) {
    // check for required params
    verifyRequiredParams(array('call'));
    $response = array();
    $call = $app->request->post('call');
    global $user_id;
    $db = new Calls();
    // creating new call
    $call_id = $db->createCall($user_id, $call);
    if ($call_id != NULL) {
        $response["error"] = false;
        $response["message"] = "Call created successfully";
        $response["call_id"] = $call_id;
    } else {
        $response["error"] = true;
        $response["message"] = "Failed to create call. Please try again";
    }
    echoRespnse(201, $response);
});
/**
 * Listing all calls of particual user
 * method GET
 * url /calls          
开发者ID:AdventureKing,项目名称:UTSASCHOOLWORK,代码行数:31,代码来源:calls.php

示例15: echoRespnse

        echoRespnse(200, $response);
    } else {
        $response["error"] = true;
        $response["message"] = "The requested resource doesn't exists";
        echoRespnse(404, $response);
    }
});
/**
 * Updating existing task
 * method PUT
 * params task, status
 * url - /tasks/:id
 */
$app->put('/tasks/:id', 'authenticate', function ($task_id) use($app) {
    // check for required params
    verifyRequiredParams(array('task', 'status'), $app->request->put());
    global $user_id;
    $task = $app->request->put('task');
    $status = $app->request->put('status');
    $db = new DbHandler();
    $response = array();
    // updating task
    $result = $db->updateTask($user_id, $task_id, $task, $status);
    if ($result) {
        // task updated successfully
        $response["error"] = false;
        $response["message"] = "Task updated successfully";
    } else {
        // task failed to update
        $response["error"] = true;
        $response["message"] = "Task failed to update. Please try again!";
开发者ID:ZillaScylla,项目名称:slim-rest,代码行数:31,代码来源:index.php


注:本文中的verifyRequiredParams函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。