Answer the question
In order to leave comments, you need to log in
Time limit for CurlHttpClient / curl or Guzzle?
It is necessary to implement chain calls to apishek in the case when one fell off for unknown reasons.
Previously use free api for your tools
use Symfony\Component\HttpClient\CurlHttpClient;
// https://api.ip.sb/geoip/*** --- было
// http://ip-api.com/php/*** --- стало, старый роут 522 более недоступен
$data = (new CurlHttpClient())
->request(Request::METHOD_GET, sprintf(' http://ip-api.com/php/%s', $ip))
->toArray()
;
Answer the question
In order to leave comments, you need to log in
https://everything.curl.dev/usingcurl/timeouts#:~:... .
...
$data = [];
foreach ($services as $service) {
try {
$data = (new CurlHttpClient())
->request(Request::METHOD_GET, sprintf('****%s', $ip), ['timeout' => 0.01])
->toArray()
;
if (true === isset($data['city'])) {
break;
}
} catch (\Exception $exception) {
$this->logError(__METHOD__, ['message' => $exception->getMessage()]);
}
}
...
return new IPInfoDTO(
$long,
$lat,
$ccAlpha2,
$postalCode
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question