laravle中使用guzzle及问题cURL error 60: SSL certificate problem: unable to get local issuer certificate

use GuzzleHttp\Client;

$client = new Client();
$response = $client->request('GET', 'http://xx.com');

$code = $response->getStatusCode();//获取http响应状态码
$data = $response->getBody()->getContents();//获取响应内容

//--GET请求添加参数
$params = [
    'headers' => [//请求头信息
        'token' => 'VBkmpUn8BPMPPNXJnP8CvneYBpQFDdfnetnxQT3C...'
    ],
    'query' => [//附加参数
        'type' => 1
    ]
];
$response = $client->request('GET','http://xx.com',$params);

//--POST请求添加参数
$params = [
    'headers' => [//请求头信息
        'token' => 'VBkmpUn8BPMPPNXJnP8CvneYBpQFDdfnetnxQT3C...'
    ],
    'form_params' => [//附加参数
        'first_name' => '周末啦',
        'last_name' => 'lalala',
        'email' => '[email protected]',
        'desc' => '周末啦周末啦周末啦周末啦',
    ],
    'json' => [//传数组
        ['name'=>'zs','age'=>10],
        ['name'=>'zs','age'=>10],
        ['name'=>'zs','age'=>10],
    ]


];
$response = $client->request('POST','http://loc.nva.com/app/message',$params);

链接:https://www.cnblogs.com/mg007/p/11202775.html

 

使用过程中报cURL error 60: SSL certificate problem: unable to get local issuer certificate错误

1.下载 cacert.pem文件

2.放在/php-7.2.1-nts/extras/ssl 文件下【本地PhpStudy环境】

3.修改php.ini文件:curl.cainfo = "F:/MyProgram/PHPTutorial/php/php-7.2.1-nts/extras/ssl/cacert.pem"

问题解决!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章