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


PHP Request::header方法代码示例

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


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

示例1: getUser

 /**
  * Retrieve the authenticated User.
  *
  * @param  Request  $request
  * @return App\Models\User|bool
  */
 public function getUser($request)
 {
     $uid = $request->header('ID');
     $token = $request->header('X-Auth-Token');
     $user = Sentinel::findById($uid);
     if ($user->api_token == $token) {
         return $user;
     }
     return false;
 }
开发者ID:vinlore,项目名称:huddle,代码行数:16,代码来源:Controller.php

示例2: user

 public static function user()
 {
     if (self::$user !== false) {
         return self::$user;
     }
     FacebookSession::setDefaultApplication(\Config::get('fb-auth::config.facebook_app_id'), \Config::get('fb-auth::config.facebook_secret'));
     $token = \Input::get('accessToken');
     if (!$token) {
         $token = \Request::header('FB-Access-Token');
     }
     if (!$token) {
         self::$user = null;
         return null;
     }
     $session = new FacebookSession($token);
     try {
         $me = (new FacebookRequest($session, 'GET', '/me'))->execute()->getGraphObject(GraphUser::className());
         self::$user = \User::from_fb($me);
     } catch (FacebookAuthorizationException $e) {
         self::$user = null;
     } catch (FacebookRequestException $e) {
         self::$user = null;
     } catch (\Exception $e) {
         self::$user = null;
     }
     return self::$user;
 }
开发者ID:benallfree,项目名称:laravel-fb-auth,代码行数:27,代码来源:Auth.php

示例3: login

 public function login(User $user, Request $request)
 {
     $response = array();
     $cell = \Input::get('cell');
     $password = \Input::get('password');
     $data = UserNew::where('cellphone', '=', $cell)->first();
     $device = \Request::header('User-Agent');
     if (sizeof($data) > 0) {
         $key = $data->api_key;
     } else {
         $key = "no key";
     }
     if (sizeof($data) > 0) {
         $response["error"] = false;
         $response['name'] = $data->name;
         $response['cell_no'] = $data->cellphone;
         $response['apiKey'] = $data->api_key;
         $response['api_key'] = $key;
         $response['createdAt'] = $data->created_at;
         \Log::info("Login Device:" . $device . ", User Cell:" . $cell . ", User Names:" . $data->name);
     } else {
         $response['error'] = true;
         $response['message'] = 'Login failed. Incorrect credentials';
     }
     return \Response::json($response);
 }
开发者ID:elieishimwe,项目名称:SiyaleaderMobileApi,代码行数:26,代码来源:UserController.php

示例4: redirectBackWithFallback

 /**
  * Redirect back, with a fallback if no previous page.
  *
  * @param string $fallback
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 protected function redirectBackWithFallback($fallback = '/')
 {
     if (!Request::header('referer')) {
         return Redirect::to($fallback);
     }
     return Redirect::back();
 }
开发者ID:anahkiasen,项目名称:arrounded,代码行数:14,代码来源:Redirectable.php

示例5: isDiscoveryRequest

 /**
  * @return bool
  */
 protected function isDiscoveryRequest()
 {
     //This field contains a semicolon-separated list of representation schemes
     //which will be accepted in the response to this request.
     $accept = Request::header('Accept');
     return strstr($accept, XRDSDocumentBuilder::ContentType) !== false;
 }
开发者ID:smarcet,项目名称:openstackid,代码行数:10,代码来源:OpenIdController.php

示例6: register_visualization

 public function register_visualization($document_id)
 {
     $documento = \Documento::find($document_id);
     if (!$documento) {
         return \Response::json(['error' => 'No existe ningun documento con id = ' . $document_id], 200);
     }
     $auth_token = \Request::header('authorization');
     $user = \User::where('auth_token', '=', $auth_token)->first();
     $idevento = \Input::get('session_id');
     if ($idevento) {
         $evento = \Evento::find($idevento);
         if (!$evento) {
             return \Response::json(['error' => 'No existe ninguna sesión con id = ' . $idevento], 200);
         }
         $v = new \Visualizacion();
         $v->idusers = $user->id;
         $v->ideventos = $evento->ideventos;
         $v->iddocumentos = $document_id;
         $v->save();
     } else {
         // obtener todos los eventos asociados al documento
         $eventos = \DocumentosEvento::where('iddocumentos', '=', $document_id)->get();
         foreach ($eventos as $evento) {
             $v = new \Visualizacion();
             $v->idusers = $user->id;
             $v->ideventos = $evento->ideventos;
             $v->iddocumentos = $document_id;
             $v->save();
         }
     }
     return \Response::json(['success' => 1], 200);
 }
开发者ID:EMerino236,项目名称:afiperularavel,代码行数:32,代码来源:DocumentosController.php

示例7: store

 /**
  * Store a newly created upload in storage.
  *
  * @return Response
  */
 public function store()
 {
     Upload::setRules('store');
     if (!Upload::canCreate()) {
         return $this->_access_denied();
     }
     $file = Input::file('file');
     $hash = md5(microtime() . time());
     $data = [];
     $data['path'] = public_path() . '/uploads/' . $hash . '/';
     mkdir($data['path']);
     $data['url'] = url('uploads/' . $hash);
     $data['name'] = preg_replace('/[^a-zA-Z0-9_.-]/', '_', $file->getClientOriginalName());
     $data['type'] = $file->getMimeType();
     $data['size'] = $file->getSize();
     $data['uploadable_type'] = Request::header('X-Uploader-Class');
     $data['uploadable_id'] = Request::header('X-Uploader-Id') ? Request::header('X-Uploader-Id') : 0;
     $data['token'] = Request::header('X-CSRF-Token');
     $file->move($data['path'], $data['name']);
     if (property_exists($data['uploadable_type'], 'generate_image_thumbnails')) {
         Queue::push('ThumbnailService', array('path' => $data['path'] . '/' . $data['name']));
     }
     $upload = new Upload();
     $upload->fill($data);
     if (!$upload->save()) {
         return $this->_validation_error($upload);
     }
     if (Request::ajax()) {
         return Response::json($upload, 201);
     }
     return Redirect::back()->with('notification:success', $this->created_message);
 }
开发者ID:k4ml,项目名称:laravel-base,代码行数:37,代码来源:UploadsController.php

示例8: userId

function userId()
{
    $token = explode(' ', Request::header('Authorization'))[1];
    $payloadObject = JWT::decode($token, Config::get('secrets.TOKEN_SECRET'));
    $payload = json_decode(json_encode($payloadObject), true);
    return $payload['sub'];
}
开发者ID:paulstefanday,项目名称:HumbleCommunity,代码行数:7,代码来源:helpers.php

示例9: is_pjax_request

 function is_pjax_request()
 {
     if (isset(Request::header('X-PJAX-CONTAINER'))) {
         return true;
     }
     return false;
 }
开发者ID:timgws,项目名称:laravel-pjax,代码行数:7,代码来源:helpers.php

示例10: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if ($body = \Request::input('body')) {
         $translation = Translation::where('body', $body)->first();
         if ($translation) {
             $response = response()->json([['id' => $translation->getId(), 'body' => $translation->body]]);
         } else {
             $response = response()->json(['errors' => ['The translation hasn\'t found.']], 404);
         }
     } else {
         if ($autocomplete = \Request::input('autocomplete')) {
             $translations = Translation::select('body')->where('body', 'LIKE', "{$autocomplete}%")->take(\Request::header('Limit') ?: 5)->get();
             if (count($translations) > 0) {
                 $response = response()->json($translations);
             } else {
                 $response = response()->json(['errors' => ['The matched translations haven\'t found.']], 404);
             }
         } else {
             $result = Translation::paginate(\Request::header('Limit') ?: 10);
             $headers['Current-Page'] = $result->currentPage();
             $headers['Last-Page'] = $result->lastPage();
             $translations = [];
             foreach ($result as $key => $item) {
                 $translations[$key]['id'] = $item->getId();
                 $translations[$key]['body'] = $item->body;
             }
             if (count($translations) > 0) {
                 $response = response()->json($translations, 200, $headers);
             } else {
                 $response = response()->json(['errors' => ['there aren\'t any translations.']], 404);
             }
         }
     }
     return $response;
 }
开发者ID:disik69,项目名称:backend.english-roulette-v0.3,代码行数:40,代码来源:TranslationController.php

示例11: handle

 /**
  * Handle an incoming request.
  * @param $request
  * @param callable $next
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  * @throws UnLoginException
  */
 public function handle($request, Closure $next)
 {
     $resource = $this->processPermissionResource($request);
     $url = "/auth/";
     if ($resource == null || $this->user == null) {
         //            return redirect($url);
         throw new UnLoginException("没有登录", 10001, array("url" => $url));
     }
     $admin = DeepinAuthAdministrator::find($this->user->getUid());
     if (!$admin instanceof DeepinAuthAdministrator) {
         return redirect($url);
         //用户已经被删除
     }
     if (intval($admin->uid()) != 1) {
         //只有这个用户可以免除所有的权限验证
         $isOk = $this->checkPermission($admin, $resource);
         //检查权限
         if ($isOk == false) {
             $url = \Request::header("Referer");
             if (empty($url)) {
                 $url = "/admin/app";
             }
             //                return redirect($url);
             throw new UnLoginException("没有权限", 10002, array("url" => $url));
         }
     }
     return $next($request);
 }
开发者ID:snyh,项目名称:just-calc-dstore-info,代码行数:35,代码来源:DeepInAuthMiddleware.php

示例12: index

 /**
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // Use content negotiation to determine the correct format to return
     $negotiator = new \Negotiation\FormatNegotiator();
     $acceptHeader = Request::header('accept');
     // Set priorities to json (if the app requests json provide it in favor of html)
     $priorities = array('application/json', 'text/html', '*/*');
     // Get the best appropriate content type
     $result = $negotiator->getBest($acceptHeader, $priorities);
     // Default to html if $result is not set
     $val = "text/html";
     if (isset($result)) {
         $val = $result->getValue();
     }
     // See what kind of content we should return
     switch ($val) {
         case "text/html":
             // In case we want to return html, just let
             // Laravel render the view and send the headers
             return Response::view('route.planner')->header('Content-Type', "text/html")->header('Vary', 'accept');
             break;
         case "application/json":
         default:
             // In case we want to return JSON(LD) or something else, generate
             // our JSON by calling our static function 'getJSON()'
             return Response::make($this::getJSON())->header('Content-Type', "application/json")->header('Vary', 'accept');
             break;
     }
 }
开发者ID:elroyK,项目名称:hyperRail,代码行数:32,代码来源:RouteController.php

示例13: __construct

 public function __construct()
 {
     $token = Request::header('X-Auth-Token');
     $this->user = json_decode(AuthToken::validate($token));
     $this->page = Input::get('page');
     $this->per_page = Input::get('per_page');
 }
开发者ID:korrio,项目名称:wouchat-api,代码行数:7,代码来源:LiveController.php

示例14: init

 /**
  * Creates a Laravel route, returning a closure which passes the raw input to AngularPHP and returns the response
  */
 protected function init()
 {
     $route = func_get_arg(0);
     $this->setErrorHandler(function (\Exception $e, Request $r) {
         \Log::error($e, $r->toArray());
     });
     $endpoint = $this;
     \Route::any($route, function () use($endpoint) {
         $path = '/' . \Request::path();
         $referrer = \Request::header('referer');
         $host = \Request::header('host');
         if (($origin = \Request::header('Origin')) && count($this->corsHosts)) {
             $this->setCorsOrigin($origin);
         }
         /**
          * If being called remotely, add the domain name to the URI
          */
         if (strlen($referrer) && parse_url($referrer, PHP_URL_HOST) != $host) {
             $uri = '//' . $host . $path;
         } else {
             $uri = $path;
         }
         $request = new Request(\Request::json()->all());
         $response = $endpoint->setUri($uri)->execute($request, \Request::getMethod());
         return \Response::make($response->content, $response->code, $response->headers)->header('Content-Type', $response->contentType);
     });
 }
开发者ID:echobot,项目名称:angularphp,代码行数:30,代码来源:Laravel.php

示例15: __construct

 public function __construct()
 {
     //not sure
     $token = Request::header('X-Auth-Token');
     $this->user = json_decode(AuthToken::validate($token));
     $this->api_token = Input::get('api_token');
     //end not sure
 }
开发者ID:korrio,项目名称:wouchat-api,代码行数:8,代码来源:UserController.php


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