laravel-swap
laravel-swap copied to clipboard
The request call is null - Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON
Swap::latest('EUR/USD');
is throwing "Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON"
on function
public function getExchangeRate(ExchangeRateQuery $exchangeQuery): ExchangeRate
{
$exceptions = [];
foreach ($this->services as $service) {
if (!$service->supportQuery($exchangeQuery)) {
continue;
}
try {
return $service->getExchangeRate($exchangeQuery);
} catch (\Throwable $e) {
$exceptions[] = $e;
}
}
throw new ChainException($exceptions);
}
I tried to dump the request on HttpService and it returns null.
And for the buildRequest function, if I dump the $request or $this->requestFactory->createRequest('GET', $url); returns
If I dump the $content in the private function doCreateRate in the AbstractApi.php file, it just returns nothing.
I can't find where the problem is. Any ideas?
I have the same issue
Looks like it's an issue with AbstractApi's response?
The issue has been documented here: https://github.com/florianv/exchanger/blob/master/doc/readme.md#configuration
You need to setup the curl client to follow location:
$options = [
CURLOPT_FOLLOWLOCATION => true,
];
$client = new CurlClient(null, null, $options);