PHP:guzzlehttp/guzzle进行网络请求

网友投稿 720 2022-05-30

文档:

HTTPs://Guzzle-cn.readthedocs.io/zh_CN/latest/

https://packagist.org/packages/guzzlehttp/guzzle

https://docs.guzzlephp.org/en/stable/

安装

composer require guzzlehttp/guzzle

1

发送GET请求

get('http://httpbin.org/get', [ 'query' => [ 'name' => 'Tom' ] ]); echo $response->getStatusCode(); // 200 $content = $response->getBody()->getContents(); print_r($content);

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

发送POST请求

post('http://httpbin.org/post', [ 'json' => [ 'name' => 'Tom' ] ]); echo $response->getStatusCode(); // 200 $content = $response->getBody()->getContents(); print_r($content);

1

2

3

4

5

6

7

8

9

10

PHP:guzzlehttp/guzzle进行网络请求

11

12

13

14

15

16

17

18

19

PHP 网络

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Ansible — Modules
下一篇:Spring5.0源码学习系列之核心技术IoC概述(三)
相关文章