// create the data array
$data = array(
"method"=>'get_rate',
"from"=>'cad',
"to" =>'usd'
);
// encode the data into JSON
$dataJson = json_encode($data);
// create the CURL post
$ch = curl_init('https://northstarcurrency.com/api/');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataJson);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"apiKey: 12345test"
));
$output = curl_exec($ch);
curl_close($ch);
print_r($output);
Variable |
Data Type |
Example |
status |
string |
'success' or 'failed'
if status is 'failed', please see 'error' json data
|
from_currency |
varchar(3) |
CAD |
to_currency |
varchar(3) |
USD |
rate |
float(10,2) |
0.989 |
error |
string |
reason(s) of error
- invalid key
- You are not configured for this currency pair. Please contact studentpay@northstarcurrency.com to activate.
- invalid currency
|
Variable |
Data Type |
Example |
method |
string |
get_rate |
from |
varchar(3) |
CAD |
to |
varchar(3) |
USD |