米
心情
所有
图集
登录
搜索
原创
guzzlehttp/guzzle、curl包文件,可以替代curl,file_get_content,fopen等函数
柯柯
发布于:2020-09-15
虽然程序员无时无刻都在造轮子,但造轮子也有效率之分,用好轮子才能造出好“ ” ###guzzlehttp/guzzle Guzzle is a PHP HTTP client library 文档地址:http://guzzlephp.org > composer require guzzlehttp/guzzle ``` use GuzzleHttp\Client; $client = new GuzzleHttp\Client(); $response = $client->request('POST', 'http://www.baidu.com', [ 'form_params' => [ 'username' => 'coder', 'password' => '12345' ] ]); print_r($response); ``` ``` $client = new \GuzzleHttp\Client(); $response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle'); echo $response->getStatusCode(); // 200 echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8' echo $response->getBody(); // '{"id": 1420053, "name": "guzzle", ...}' // Send an asynchronous request. $request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org'); $promise = $client->sendAsync($request)->then(function ($response) { echo 'I completed! ' . $response->getBody(); }); $promise->wait(); ```
注:原创不易,转载请注明出处(
https://micuu.com/new/912.html
),本站所有资源来源于网络收集,如有侵权请联系QQ245557979进行清除。
最后修改与 2022-02-19
上一篇:
今天偶然翻到2年前自己给自己的评价,发现
下一篇:
jenssegers/date 日期处理函数PHPcomposer包文件推荐
留言反馈
请先登录
问题反馈渠道,如有软件无法下载或者其他问题可反馈。【由于某种原因,目前留言不展示】
用户需要登录后才能留言反馈
立即留言
珍藏视频
10分钟高效燃脂
30天高效瘦脸操
5分钟缓解颈椎操
友人
微博
全民K歌
唱吧
今日头条
悠悠网
科技小锅盖
彼岸桌面
阮一峰
laravel社区
V2ex
掘金
更多>