I want to fetch data from webpages using Guzzle. I have written the following code:
<?php
require_once 'vendor/autoload.php';
$client = new \GuzzleHttp\Client(['base_uri' => 'https://yandex.ru']);
$response = $client->request('GET');
$body = $response->getBody();
echo $body;
But I receive Fatal Error when I run this code on my localhost.
Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in C:\Xampp\htdocs\Guzzle\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:187 Stack trace: #0 C:\Xampp\htdocs\Guzzle\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(150): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\Xampp\htdocs\Guzzle\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(103): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 C:\Xampp\htdocs\Guzzle\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #3 C:\Xampp\htdocs\Guzzle\vendor\guzzlehttp\guzzle in C:\Xampp\htdocs\Guzzle\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 187
The problem is that when I delete the last three lines of my code, it works well, so the issue is with request. Could anyone suggest a solution?