本文整理汇总了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;
}
}
}
示例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"));
}
}
示例3: logout
/**
* Remove auth token from cache
* @return array
*/
public function logout()
{
User::invalidateToken($this->token);
return Api::response(['success' => true]);
}
示例4: __call
public function __call($method, $parameters)
{
return Api::response(array('status' => false, 'error_code' => 404, 'error_string' => 'unknown method'), 404);
}
示例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);
}
}
}
});