本文整理汇总了PHP中Api::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Api::error方法的具体用法?PHP Api::error怎么用?PHP Api::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Api
的用法示例。
在下文中一共展示了Api::error方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* Api Login
* @return array
*/
public function login()
{
$rules = ['email' => 'required_without:username|email', 'username' => 'required_without:email', 'password' => 'required'];
$validate = Hyfn::validate($rules);
if ($validate !== true) {
return Api::error($validate->errors()->getMessages());
}
$input = array('email' => Input::get('email'), 'username' => Input::get('username'), 'password' => Input::get('password'));
$user = new User();
$login = $user->login($input);
if ($login !== true) {
return Api::error($login);
}
$token = $user->token;
$user = User::getFromToken($token);
$user = $user->toArray();
$user['token'] = $token;
return Api::response($user);
}
示例2: array
<?php
require "include/connect.php";
// Соединение с БД
/** @section Бизнес-логика */
/** @section Обработка запросов */
$response = array();
$method = strtolower(_::str('method'));
switch ($method) {
/** @subsection Обработка запросов к Api */
/** @subsection Обработка ошибочного запроса */
default:
Api::error(0, $method . ' : Неверный запрос к Api');
// Все прочие запросы игнорируются
}
Api::out($response);
示例3: function
}
});
/**
* Authenticate valid auth token key
*/
Route::filter('auth.token', function () {
// Validate api key
$rules = ['token' => 'required'];
$validate = Hyfn::validate($rules);
// Invalid API key
if ($validate !== true) {
return Api::error($validate->errors()->getMessages(), 401);
}
$validToken = User::isValidToken(Input::get('token'));
if ($validToken !== true) {
return Api::error(Lang::get('errors.invalid_token'), 401);
}
});
Route::filter('auth.basic', function () {
return Auth::basic();
});
/*
|--------------------------------------------------------------------------
| Guest Filter
|--------------------------------------------------------------------------
|
| The "guest" filter is the counterpart of the authentication filters as
| it simply checks that the current user is not logged in. A redirect
| response will be issued if they are, which you may freely change.
|
*/
示例4: array
return Api::error(Lang::get('errors.404'), 404);
}
return Response::view('errors.404', array(), 404);
});
/*
|--------------------------------------------------------------------------
| Maintenance Mode Handler
|--------------------------------------------------------------------------
|
| The "down" Artisan command gives you the ability to put an application
| into maintenance mode. Here, you will define what is displayed back
| to the user if maintenace mode is in effect for this application.
|
*/
App::down(function () {
if (Request::is('api/*')) {
return Api::error(Lang::get('errors.503'), 503);
}
return Response::view('errors.maint', array(), 503);
});
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
require app_path() . '/filters.php';