首页 > 其他 > 详细

laravel guzzle 发起请求

时间:2020-04-25 19:13:58      阅读:60      评论:0      收藏:0      [点我收藏+]

1、安装guzzle

composer require guzzlehttp/guzzle

2、引入

use GuzzleHttp\Client;

3、发起请求

        //发起Http请求  并设置超时时间
        $client = new Client([‘timeout‘=>5]);
        //得到URL地址
        $url=config(‘gaode.geocode‘);
        //替换占位符$url=sprintf($url,$model->fang_addr,$city->name);
        //发起请求
        $response=$client->get($url);
        //可尝试 打印$response看看
        $body=(string)$response->getBody();
//格式化
$arr=json_decode($body,true);
     /*
      * 对数据进行处理
     */      

 

laravel guzzle 发起请求

原文:https://www.cnblogs.com/zqblog1314/p/12774546.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!