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


PHP Api::response方法代码示例

本文整理汇总了PHP中Api::response方法的典型用法代码示例。如果您正苦于以下问题:PHP Api::response方法的具体用法?PHP Api::response怎么用?PHP Api::response使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Api的用法示例。


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

示例1: callHook

function callHook()
{
    global $url;
    global $default;
    global $controller;
    $queryString = array();
    if (!isset($url)) {
        $controller = $default['controller'];
        $action = $default['action'];
    } else {
        $url = routeURL($url);
        $urlArray = array();
        $urlArray = explode("/", $url);
        $urlArray = array_filter($urlArray);
        $controller = $urlArray[0];
        array_shift($urlArray);
        if (isset($urlArray[0])) {
            $action = $urlArray[0];
            array_shift($urlArray);
        } else {
            $action = 'index';
            // Default Action
        }
        $queryString = $urlArray;
    }
    $controllerName = ucfirst($controller) . 'Controller';
    // Check to see if the controller exists
    if (!file_exists('../application/controllers/' . $controllerName . '.php')) {
        if (isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'application/json') {
            // Serve up some JSON
            $dispatch = new Api();
            $dispatch->response('Endpoint not found', 404);
        } else {
            // Serve up some HTML
            $dispatch = new ErrorController();
            call_user_func_array(array($dispatch, 'notFound'), []);
            exit;
        }
    }
    $dispatch = new $controllerName($controller, $action);
    if ((int) method_exists($controllerName, $action)) {
        call_user_func_array(array($dispatch, "beforeAction"), $queryString);
        call_user_func_array(array($dispatch, $action), $queryString);
        call_user_func_array(array($dispatch, "afterAction"), $queryString);
    } else {
        // We should check the Accept header type to server up the correct 404
        if (isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'application/json') {
            // Serve up some JSON
            $dispatch = new Api();
            $dispatch->response('Endpoint not found', 404);
        } else {
            // Serve up some HTML
            $dispatch = new ErrorController();
            call_user_func_array(array($dispatch, 'notFound'), []);
            exit;
        }
    }
}
开发者ID:rorystandley,项目名称:php-mvc,代码行数:58,代码来源:application.php

示例2: getStoresAlgolia

 public function getStoresAlgolia($coordinate)
 {
     $latitude = $this->getLatitude($coordinate);
     $longitude = $this->getLongitude($coordinate);
     $client = new \AlgoliaSearch\Client(APPLICATION_ID, API_KEY);
     $index = $client->initIndex(INDEX_STORES);
     $query = $index->search("", array("aroundLatLng" => "{$latitude},{$longitude}", "aroundRadius" => 1000));
     if ($this->validateNbHits($query)) {
         parent::response($response_code = 200, $this->arrayInformation($query));
     } else {
         parent::response($response_code = 404, array("stores" => 0, "message" => "Stores near not found"));
     }
 }
开发者ID:Ludim,项目名称:api.shoptive.com,代码行数:13,代码来源:rest.php

示例3: logout

 /**
  * Remove auth token from cache
  * @return array
  */
 public function logout()
 {
     User::invalidateToken($this->token);
     return Api::response(['success' => true]);
 }
开发者ID:viniciusferreira,项目名称:laravel-skeleton,代码行数:9,代码来源:UserController.php

示例4: __call

 public function __call($method, $parameters)
 {
     return Api::response(array('status' => false, 'error_code' => 404, 'error_string' => 'unknown method'), 404);
 }
开发者ID:SerdarSanri,项目名称:RestServiceApi,代码行数:4,代码来源:api_controller.php

示例5: array

            // delete
            Route::delete('{id}', array("as" => "groups.destroy", "uses" => "Agkunz\\User\\GroupController@destroy"));
        });
    });
    // jesus please dear god don't use this
    Route::get("reset", array("as" => "dev.api.reset", "uses" => "Agkunz\\Api\\ApiController@reset"));
    // this is a work route to get your hmac
    Route::get('{email}', function ($email) {
        $key = Sentry::findUserByLogin($email)->getApiKey();
        $data = array('email' => $email, 'timestamp' => time());
        $hash_string = json_encode($data);
        $hmac = hash_hmac('sha256', $hash_string, $key);
        $data['hmac'] = $hmac;
        dd($data);
    });
});
Route::filter('apiauth', function () {
    if (!Api::authenticate()) {
        return Api::response(false);
    }
});
Route::filter('byroute', function () {
    if ($user = Config::get('user')) {
        if (!$user->hasPermission("superuser")) {
            if (!$user->hasPermission(Route::getCurrentRoute())) {
                MessageBag::add("error", "You don't have permission to use this route.");
                return Api::response(false);
            }
        }
    }
});
开发者ID:agkunz,项目名称:user,代码行数:31,代码来源:routes.php


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