當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::getBody方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Facades\Request::getBody方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getBody方法的具體用法?PHP Request::getBody怎麽用?PHP Request::getBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Facades\Request的用法示例。


在下文中一共展示了Request::getBody方法的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::getBody方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。