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


PHP Request::getHeader方法代码示例

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


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

示例1: toApi

 public function toApi(Request $request)
 {
     $client = new \GuzzleHttp\Client();
     $input = $request::all();
     $command = 'request';
     $api_key = 'MjuhMtfAAfvJqzbnWFLA';
     // $api_key = 'mysendykey';
     $api_username = 'chris-stop';
     // $api_username = 'mysendyusername';
     $from_name = 'Chris Munialo';
     $from_lat = $input['lat'];
     $from_long = $input['lng'];
     $from_description = '';
     $to_name = 'TRM';
     $to_lat = $input['lat1'];
     $to_long = $input['lng1'];
     $to_description = '';
     $recepient_name = 'John';
     $recepient_phone = '0710000000';
     $recepient_email = 'John@doe.com';
     $pick_up_date = '2016-04-20 12:12:12';
     $status = false;
     $pay_method = 0;
     $amount = 10;
     $return = true;
     $note = 'Sample note';
     $note_status = true;
     $request_type = 'quote';
     $info = ['command' => $command, 'data' => ['api_key' => $api_key, 'api_username' => $api_username, 'from' => ['from_name' => $from_name, 'from_lat' => floatval($from_lat), 'from_long' => floatval($from_long), 'from_description' => $from_description], 'to' => ['to_name' => $to_name, 'to_lat' => floatval($to_lat), 'to_long' => floatval($to_long), 'to_description' => $to_description], 'recepient' => ['recepient_name' => $recepient_name, 'recepient_phone' => $recepient_phone, 'recepient_email' => $recepient_email], 'delivery_details' => ['pick_up_date' => $pick_up_date, 'collect_payment' => ['status' => $status, 'pay_method' => $pay_method, 'amount' => $amount], 'return' => $return, 'note' => $note, 'note_status' => $note_status, 'request_type' => $request_type]]];
     $clientHandler = $client->getConfig('handler');
     // Create a middleware that echoes parts of the request.
     $tapMiddleware = Middleware::tap(function ($request) {
         $request->getHeader('Content-Type');
         // application/json
         $request->getBody();
         // {"foo":"bar"}
     });
     $endpoint = 'https://developer.sendyit.com/v1/api/#request';
     // $info = json_encode($info);
     $client = new \GuzzleHttp\Client();
     $res = $client->request('POST', $endpoint, ['json' => $info, 'handler' => $tapMiddleware($clientHandler), 'headers' => ['Accept' => 'application/json']]);
     // $res->getStatusCode();
     // "200"
     // $res->getHeader('content-type');
     // 'application/json; charset=utf8'
     $pns = json_decode($res->getBody(), true);
     // var_dump($pns);
     // echo $pns;
     // echo $pns;
     // $pns= $res->getBody();
     // {"type":"User"...
     // Send an asynchronous request.
     // $request = new \GuzzleHttp\Psr7\Request('POST', $endpoint );
     // $promise = $client->sendAsync($request)->then(function ($response) {
     // $response->getBody();
     // });
     // $promise->wait();
     return view('orders.new', ['pns' => $pns]);
 }
开发者ID:krysmunialo,项目名称:sendy---request_delivery,代码行数:59,代码来源:OrdersController.php


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