Use curl to get rates from CurrecyLayer API

This commit is contained in:
Mavyre 2018-05-30 21:14:51 +02:00 committed by GitHub
parent e59a91bdae
commit ace57859e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -626,6 +626,15 @@ class MultiCurrency extends CommonObject
{ {
global $db,$conf; global $db,$conf;
$ch = curl_init('http://apilayer.net/api/live?access_key='.$key.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode($response);
if ($response->success)
{
$TRate = $response->quotes; $TRate = $response->quotes;
$timestamp = $response->timestamp; $timestamp = $response->timestamp;
@ -646,6 +655,11 @@ class MultiCurrency extends CommonObject
} }
} }
} }
else
{
setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors');
}
}
/** /**
* Check in database if the current code already exists * Check in database if the current code already exists