本文整理汇总了PHP中errorResponse函数的典型用法代码示例。如果您正苦于以下问题:PHP errorResponse函数的具体用法?PHP errorResponse怎么用?PHP errorResponse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了errorResponse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: generate
public function generate(Request $request)
{
$data = $request->all();
$validator = Validator::make($data, ['token' => 'required', 'number' => 'required']);
if ($validator->fails()) {
return validatorError($validator->errors());
}
$token = $this->getToken($data['token']);
if (!$token->owner->hasApiEnabled($this->api)) {
return errorResponse('api_disabled', 403);
}
if ($token == null) {
return errorResponse("token_invalid", 403);
}
if (!$token->enabled) {
return errorResponse("token_disabled", 403);
}
if (!$token->validDayLimit()) {
return errorResponse('day_limit_reached', 403);
}
if (!$token->validMonthLimit()) {
return errorResponse('month_limit_reached', 403);
}
$verification = Verification::create(['phone_number' => $data['number'], 'code' => $this->incrementalHash($this->api->configuration->token_length), 'expiration' => Carbon::now()->addMinutes($this->api->configuration->expiration)]);
$sms = $this->api->configuration->message_content;
$sms = str_replace("\\(code)", $verification->code, $sms);
$this->sendApiRequest($data['number'], $sms, $token->owner->id);
return successResponse('sent');
}
开发者ID:ptrstovka,项目名称:sms-gateway,代码行数:29,代码来源:VerificationServiceController.php
示例2: validateNotEmpty
function validateNotEmpty($string)
{
if (empty(trim($string))) {
errorResponse();
return false;
}
return true;
}
开发者ID:hcr,项目名称:php-email-service,代码行数:8,代码来源:email-service.php
示例3: setMessageBody
/**
* Pulls posted values for all fields in $fields_req array.
* If a required field does not have a value, an error response is given.
*
* @param [Array] $fields_req a map of field name to required
*/
function setMessageBody($fields_req)
{
$message_body = "";
foreach ($fields_req as $name => $required) {
if ($required && empty($name)) {
errorResponse("{$name} is empty.");
} else {
$message_body .= ucfirst($name) . ": " . $_POST[$name] . "\n";
}
}
return $message_body;
}
开发者ID:Rishanth,项目名称:Online-Consultants,代码行数:18,代码来源:sendmail.php
示例4: constructMessageBody
/**
* Pulls posted values for all fields in $fields_req array.
* If a required field does not have a value, an error response is given.
*/
function constructMessageBody()
{
$fields_req = array("name" => true, "email" => true, "message" => true);
$message_body = "";
foreach ($fields_req as $name => $required) {
$postedValue = $_POST[$name];
if ($required && empty($postedValue)) {
errorResponse("{$name} is empty.");
} else {
$message_body .= ucfirst($name) . ": " . $postedValue . "\n";
}
}
return $message_body;
}
开发者ID:joksin,项目名称:bootstrap3-contact-form,代码行数:18,代码来源:sendmail.php
示例5: errorResponse
if (isset($_GET['current'])) {
$tripId = Trip::findCurrentTrip();
if (!$tripId) {
$tripId = '';
}
} else {
if (isset($_GET['tripId'])) {
$tripId = $_GET['tripId'];
}
}
if ($tripId === '') {
$response = errorResponse(RESPONSE_BAD_REQUEST);
} else {
$object = new Trip($tripId);
if ($object->getCreated() === null) {
$response = errorResponse(RESPONSE_NOT_FOUND);
} else {
$response = successResponse();
$response['tripId'] = $object->getTripId();
$response['created'] = $object->getCreated();
$response['updated'] = $object->getUpdated();
$response['name'] = $object->getName();
$response['description'] = $object->getDescription();
$response['bannerImg'] = $object->getBannerImg();
$response['startDate'] = $object->getStartDate();
$response['endDate'] = $object->getEndDate();
$response['active'] = $object->getActive();
$response['deleted'] = $object->getDeleted();
// Do NOT return the hash field on the GET service.
$journal = Journal::getFirstJournal($object->getTripId());
if ($journal !== null) {
开发者ID:egrivel,项目名称:vacationblog,代码行数:31,代码来源:getTrip.php
示例6: errorResponse
if (isset($data['password'])) {
$password = $data['password'];
}
if ($userId === '' || $password === '') {
$response = errorResponse(RESPONSE_BAD_REQUEST);
} else {
$user = new User($userId);
if ($user->getCreated() === null) {
$response = errorResponse(RESPONSE_NOT_FOUND);
} else {
if ($user->checkPassword($password)) {
// password matches, need to allow for hash update (if hash
// algorithm changed, the new hash can only be stored in the
// database when we have the actual password, and only at login
// time do we have the actual password)
$user->updatePasswordHash($password);
$authId = Auth::generateAuthId();
$auth = new Auth($authId);
$auth->setUserId($userId);
$auth->save();
$response = successResponse();
$response['authId'] = $authId;
} else {
$response = errorResponse(RESPONSE_UNAUTHORIZED);
}
}
}
} else {
$response = errorResponse(RESPONSE_METHOD_NOT_ALLOWED, $_SERVER['REQUEST_METHOD']);
}
echo json_encode($response);
开发者ID:egrivel,项目名称:vacationblog,代码行数:31,代码来源:login.php
示例7: Cancellation
exit;
}
$email = Configuration::get($prefix . 'EMAIL');
$token = Configuration::get($prefix . 'TOKEN');
$cancellation = new Cancellation($email, $token);
$cancellation->enableSandBox(Configuration::get($prefix . 'SANDBOX'));
try {
$response = $cancellation->execute($id_transacao);
if ($response->transactionStatusId == 7 || $response->transactionStatusId == 6) {
updateOrder($id_pedido, $response);
writeHistory($id_pedido, $response);
}
} catch (ValidationException $e) {
die(errorResponse($e));
} catch (ConnectionException $e) {
die(errorResponse($e));
}
echo json_encode($response);
exit;
function errorResponse($e)
{
$erros = $e->getErrors();
if (!empty($erros)) {
return $e->getErrors()->list[0]->description;
}
}
function updateOrder($orderId, $response)
{
$order_state_id = (int) Configuration::get('PS_OS_BCASH_CANCELLED');
if ($response->transactionStatusId == 6) {
$order_state_id = (int) Configuration::get('PS_OS_BCASH_REFUNDED');
开发者ID:payu-br,项目名称:bcash-prestashop-transparente,代码行数:31,代码来源:ServiceCancelation.php
示例8: successResponse
$object->setAccess($data['access']);
}
if (isset($data['email'])) {
$object->setEmail($data['email']);
}
if (isset($data['notification'])) {
$object->setNotification($data['notification']);
}
if (isset($data['tempCode'])) {
$object->setTempCode($data['tempCode']);
}
if (isset($data['deleted'])) {
$object->setDeleted($data['deleted']);
}
if (isset($data['hash'])) {
$object->setHash($data['hash']);
}
if ($object->save()) {
$response = successResponse();
} else {
$response = errorResponse(RESPONSE_INTERNAL_ERROR);
}
} else {
$response = errorResponse(RESPONSE_BAD_REQUEST, 'Need user ID');
}
} else {
$response = errorResponse(RESPONSE_METHOD_NOT_ALLOWED);
}
}
}
echo json_encode($response);
开发者ID:egrivel,项目名称:vacationblog,代码行数:31,代码来源:synchUser.php
示例9: TripAttribute
$name = $data['name'];
$object = new TripAttribute($tripId, $name);
if (isset($data['created'])) {
$object->setCreated($data['created']);
}
if (isset($data['updated'])) {
$object->setUpdated($data['updated']);
}
if (isset($data['value'])) {
$object->setValue($data['value']);
}
if (isset($data['deleted'])) {
$object->setDeleted($data['deleted']);
}
if (isset($data['hash'])) {
$object->setHash($data['hash']);
}
if ($object->save()) {
$response = successResponse();
} else {
$response = errorResponse(RESPONSE_INTERNAL_ERROR);
}
} else {
$response = errorResponse(RESPONSE_BAD_REQUEST);
}
} else {
$response = errorResponse(RESPONSE_BAD_REQUEST);
}
}
}
echo json_encode($response);
开发者ID:egrivel,项目名称:vacationblog,代码行数:31,代码来源:synchTripAttribute.php
示例10: successResponse
$object->setUserId($data['userId']);
}
if (isset($data['journalDate'])) {
$object->setJournalDate($data['journalDate']);
}
if (isset($data['journalTitle'])) {
$object->setJournalTitle($data['journalTitle']);
}
if (isset($data['journalText'])) {
$object->setJournalText($data['journalText']);
}
if (isset($data['deleted'])) {
$object->setDeleted($data['deleted']);
}
if (isset($data['hash'])) {
$object->setHash($data['hash']);
}
if ($object->save()) {
$response = successResponse();
} else {
$response = errorResponse(RESPONSE_INTERNAL_ERROR);
}
} else {
$response = errorResponse(RESPONSE_BAD_REQUEST, 'tripId or journalId not set');
}
} else {
$response = errorResponse(RESPONSE_BAD_REQUEST, 'not GET or PUT response');
}
}
}
echo json_encode($response);
开发者ID:egrivel,项目名称:vacationblog,代码行数:31,代码来源:synchJournal.php
示例11: array_push
}
$step_array['step_progress'] = $step_progress_array;
}
}
array_push($steps_array, $step_array);
}
$task_array['steps'] = $steps_array;
array_push($tasks_array, $task_array);
}
$response_array = array("status" => "ok", "module_id" => $module_id, "tasks" => $tasks_array);
$response = json_encode($response_array);
} else {
$response = errorResponse("The module id provided is not valid");
}
} else {
$response = errorResponse("module_id is expected");
}
}
echo $response;
function taskByModuleId($module_id)
{
return getTaskByModuleId($module_id);
}
function getTaskByModuleId($module_id)
{
$sql = sprintf("SELECT t.task_id, name, brief_desc, t.desc, thumb_url FROM task t JOIN module_task mt ON t.task_id = mt.task_id WHERE module_id = %d", $module_id);
return executeSql($sql);
}
function taskProgressByTaskIdUserId($task_id, $user_id)
{
return getTaskProgressByTaskIdUserId($task_id, $user_id);
开发者ID:isader,项目名称:notgoalifyoz,代码行数:31,代码来源:task.php
示例12: isset
$module_id = isset($module_id) ? $module_id : $_GET['module_id'];
$show_all_for_user = isset($show_all_for_user) ? $show_all_for_user : $_GET['show_all_for_user'];
$new_module = isset($new_module) ? $new_module : $_POST['new_module'];
$response = "";
if ($user_id && !$show_all_for_user) {
if (checkId($user_id)) {
$response = moduleByUserId($user_id);
} else {
$response = errorResponse("The user id provided is not valid");
}
} else {
if ($module_id) {
if (checkId($module_id)) {
$response = moduleByModuleId($module_id);
} else {
$response = errorResponse("The module id provided is not valid");
}
} else {
if ($new_module) {
$user_id = intval($_POST['user_id']);
$module_id = intval($_POST['module_id']);
$progress = checkString($_POST['progress']);
$is_complete = checkString($_POST['is_complete']);
$date_completed = checkString($_POST['date_completed']);
if (checkId($user_id) && checkId($module_id)) {
$response = moduleUserProgress($user_id, $module_id, $progress, $is_complete, $date_completed);
}
} else {
$response = allModules($user_id);
}
}
开发者ID:isader,项目名称:notgoalifyoz,代码行数:31,代码来源:module.php
示例13: successResponse
$object->setUserId($data['userId']);
}
if (isset($data['referenceId'])) {
$object->setReferenceId($data['referenceId']);
}
if (isset($data['commentText'])) {
$object->setCommentText($data['commentText']);
}
if (isset($data['deleted'])) {
$object->setDeleted($data['deleted']);
}
if (isset($data['hash'])) {
$object->setHash($data['hash']);
}
if ($object->save()) {
$response = successResponse();
} else {
// @codeCoverageIgnoreStart
// cannot unit test database errors
$response = errorResponse(RESPONSE_INTERNAL_ERROR);
// @codeCoverageIgnoreEnd
}
} else {
$response = errorResponse(RESPONSE_BAD_REQUEST);
}
} else {
$response = errorResponse(RESPONSE_METHOD_NOT_ALLOWED, 'must be get or put');
}
}
}
echo json_encode($response);
开发者ID:egrivel,项目名称:vacationblog,代码行数:31,代码来源:synchComment.php
示例14: isset
<?php
include_once "connect.php";
include_once "common.php";
$user_id = isset($user_id) ? $user_id : $_GET['user_id'];
$response = "";
if ($user_id) {
if (checkId($user_id)) {
$response = userById($user_id);
} else {
$response = errorResponse("The user id provided is not valid");
}
} else {
$response = errorResponse("The user id was not provided");
}
echo $response;
function userById($user_id)
{
$result = getUserById($user_id);
return formJson($result);
}
function getUserById($user_id)
{
$sql = sprintf("SELECT user_id, first_name, last_name, age, email, receive_notifications, is_new, lang_id FROM user WHERE user_id = '%d'", $user_id);
return executeSql($sql);
}
function formJson($result)
{
$users = array();
while ($item = mysql_fetch_array($result)) {
$user = array("user_id" => $item['user_id'], "first_name" => $item['first_name'], "last_name" => $item['last_name'], "age" => $item['age'], "email" => $item['email'], "receive_notifications" => $item['receive_notifications'], "is_new" => $item['is_new'], "lang_id" => $item['lang_id']);
开发者ID:isader,项目名称:notgoalifyoz,代码行数:31,代码来源:user.php
示例15: sendSmsTemplate
public function sendSmsTemplate(Request $request)
{
$data = $request->all();
$validator = Validator::make($data, ['token' => 'required', 'template' => 'required', 'number' => 'required']);
if ($validator->fails()) {
return validatorError($validator->errors());
}
$token = $this->getToken($data['token']);
if ($token == null) {
return errorResponse("token_invalid", 403);
}
if (!$token->enabled) {
return errorResponse("token_disabled", 403);
}
if (!$token->validDayLimit()) {
return errorResponse('day_limit_reached', 403);
}
if (!$token->validMonthLimit()) {
return errorResponse('month_limit_reached', 403);
}
$template = SmsTemplate::where('sms_id', $data['template'])->first();
if ($template == null) {
return errorResponse('template_not_found', 404);
}
$forFill = $data;
unset($forFill['token']);
unset($forFill['template']);
$template->fillData($forFill);
$this->sendApiRequest($data['number'], $template->getFilled(), $token->owner->id);
return successResponse('sent');
}
开发者ID:ptrstovka,项目名称:sms-gateway,代码行数:31,代码来源:GatewayController.php
示例16: successResponse
$object->setExternalType($data['externalType']);
}
if (isset($data['externalId'])) {
$object->setExternalId($data['externalId']);
}
if (isset($data['access'])) {
$object->setAccess($data['access']);
}
if (isset($data['email'])) {
$object->setEmail($data['email']);
}
if (isset($data['notification'])) {
$object->setNotification($data['notification']);
}
if (isset($data['tempCode'])) {
$object->setTempCode($data['tempCode']);
}
if (isset($data['deleted'])) {
$object->setDeleted($data['deleted']);
}
if ($object->save()) {
$response = successResponse();
} else {
$response = errorResponse(RESPONSE_INTERNAL_ERROR);
}
}
}
} else {
$response = errorResponse(RESPONSE_METHOD_NOT_ALLOWED, 'Use Put method');
}
echo json_encode($response);
开发者ID:egrivel,项目名称:vacationblog,代码行数:31,代码来源:putUser.php
示例17: errorResponse
} else {
if (!$auth->canPutComment($tripId, $commentId)) {
$response = errorResponse(RESPONSE_UNAUTHORIZED);
} else {
$object = new Comment($tripId, $commentId);
if (isset($data['userId'])) {
$object->setUserId($data['userId']);
}
if (isset($data['referenceId'])) {
$object->setReferenceId($data['referenceId']);
}
if (isset($data['commentText'])) {
$object->setCommentText($data['commentText']);
}
if (isset($data['deleted'])) {
$object->setDeleted($data['deleted']);
}
if ($object->save()) {
$response = successResponse();
} else {
// @codeCoverageIgnoreStart
// cannot unit test database errors
$response = errorResponse(RESPONSE_INTERNAL_ERROR);
// @codeCoverageIgnoreEnd
}
}
}
} else {
$response = errorResponse(RESPONSE_METHOD_NOT_ALLOWED, 'Must use PUT method');
}
echo json_encode($response);
开发者ID:egrivel,项目名称:vacationblog,代码行数:31,代码来源:putComment.php
示例18: errorResponse
$result = errorResponse("Incorrect article identifier");
die($result);
}
// try to load the blog info too, as we are going to need it
$blogs = new Blogs();
$blogInfo = $blogs->getBlogInfo($article->getBlog());
// a bit of protection...
if (!$blogInfo) {
trackbackLog("ERROR: Article id " . $article->getId() . " points to blog " . $article->getBlog() . " that doesn't exist!");
$result = errorResponse("The blog does not exist");
die($result);
}
// if the blog is disabled, then we shoulnd't take trackbacks...
if ($blogInfo->getStatus() != BLOG_STATUS_ACTIVE) {
trackbackLog("ERROR: The blog " . $blogInfo->getBlog() . " is set as disabled and cannot receive trackbacks!");
$result = errorResponse("The blog is not active");
die($result);
}
// if everything went fine, load the plugins so that we can throw some events...
$pm =& PluginManager::getPluginManager();
$pm->loadPlugins();
// and also configure the BlogInfo and UserInfo objects so that they know
// who threw the events...
$pm->setBlogInfo($blogInfo);
$userInfo = $blogInfo->getOwnerInfo();
$pm->setUserInfo($userInfo);
// receives the request and adds it to the database
$trackbacks = new TrackBacks();
// create teh trackback object
$now = new Timestamp();
$trackback = new Trackback($url, $title, $articleId, $excerpt, $blogName, $now->getTimestamp());
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:31,代码来源:trackback.php
示例19: setMessageBody
* Comment: <message/comment submitted by user>
*
* @param String $name name of submitter
* @param String $message message/comment submitted
*/
function setMessageBody($name, $message)
{
$message_body = "Name: " . $name . "\n\n";
$message_body .= "Comment:\n" . nl2br($message);
return $message_body;
}
$email = $_POST['email'];
$message = $_POST['message'];
header('Content-type: application/json');
//do some simple validation. this should have been validated on the client-side also
if (empty($email) || empty($message)) {
errorResponse('Email or message is empty.');
}
//do Captcha check, make sure the submitter is not a robot:)...
include_once './vender/securimage/securimage.php';
$securimage = new Securimage();
if (!$securimage->check($_POST['captcha_code'])) {
errorResponse('Invalid Security Code');
}
//try to send the message
if (mail(MY_EMAIL, "Newspective Contact", setMessageBody($_POST["name"], $message), "From: {$email}")) {
echo json_encode(array('message' => 'Your message was successfully submitted.'));
} else {
header('HTTP/1.1 500 Internal Server Error');
echo json_encode(array('message' => 'Unexpected error while attempting to send e-mail.'));
}
开发者ID:Nong-Surapon,项目名称:newspective,代码行数:31,代码来源:sendmail.php
示例20: Media
$object = new Media($tripId, $mediaId);
if (isset($data['type'])) {
$object->setType($data['type']);
}
if (isset($data['caption'])) {
$object->setCaption($data['caption']);
}
if (isset($data['timestamp'])) {
$object->setTimestamp($data['timestamp']);
}
if (isset($data['location'])) {
$object->setLocation($data['location']);
}
if (isset($data['width'])) {
$object->setWidth($data['width']);
}
if (isset($data['height'])) {
$object->setHeight($data['height']);
}
if (isset($data['deleted'])) {
$object->setDeleted($data['deleted']);
}
if ($object->save()) {
$response = successResponse();
} else {
$response = errorResponse(RESPONSE_INTERNAL_ERROR);
}
}
}
}
echo json_encode($response);
开发者ID:egrivel,项目名称:vacationblog,代码行数:31,代码来源:putMedia.php
注:本文中的errorResponse函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论