Guzzle使用指南

2017-07-03  本文已影响0人  Ganodermaking

安装

composer require guzzlehttp/guzzle

GET请求

$client = new\GuzzleHttp\Client();

$options = [

    'mobile'=>1350000000

];

$request=$client->get($uri,$options);

$result=$request->getBody()->getContents();

POST请求

$client = new\GuzzleHttp\Client();

$options = [

    'mobile'=>1350000000

];

$request=$client->get($uri,$options);

$result=$request->getBody()->getContents();

body体请求

$body = ''; // xml或者json 

$client = new\GuzzleHttp\Client();

$options = [

    'body' => $body

];

$request=$client->get($uri,$options);

$result=$request->getBody()->getContents();

上一篇下一篇

猜你喜欢

热点阅读