You may be connection timeout error, while making API request via Guzzle. It may caused by following issues.
1. Check your internet connectivity.
2. It may be misconfiguration of IPV6 in your server. So you may need disable IPV6 or set the priority to IPV4.
Just follow below tutorial to set priority to IPV4 over IPV6.
https://forum.smarttutorials.net/2020/06/checking-http-connectivity-to-packagist-fail-composer-Linux.html
Provide following option to Guzzle while making HTTP request.
'force_ip_resolve' => 'v4',
GET Request
<?php
use GuzzleHttp\Client as Guzzle;
$guzzle = new Guzzle();
$res = $guzzle->get($api_url, [
'http_errors' => false,
'verify' => false,
'force_ip_resolve' => 'v4',
'query' => [
'user' => 'muni'
]
]);
POST Request
<?php
use GuzzleHttp\Client as Guzzle;
$guzzle = new Guzzle();
$guzzle->request('post', $api_url, [
'http_errors' => false,
'verify' => false,
'force_ip_resolve' => 'v4',
'form_params' => [
'request_url' => $url,
'name' => 'muni'
]
]);
0 comments:
Post a Comment