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


PHP Api::error方法代码示例

本文整理汇总了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);
 }
开发者ID:viniciusferreira,项目名称:laravel-skeleton,代码行数:23,代码来源:UserController.php

示例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);
开发者ID:greenprojectme,项目名称:template,代码行数:16,代码来源:server.php

示例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.
|
*/
开发者ID:viniciusferreira,项目名称:laravel-skeleton,代码行数:31,代码来源:filters.php

示例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';
开发者ID:viniciusferreira,项目名称:laravel-skeleton,代码行数:31,代码来源:global.php


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