本文整理汇总了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]);
}