-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exchangor.php
32 lines (25 loc) · 903 Bytes
/
Exchangor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/*
* Utility to notify you when you have favourable exchange rates
* @Author Nibin
*/
require '/var/www/html/email_client.php';
$threshold=$argv[1];
$receiver=$argv[2];
$API_SECRET=$argv[3];
$CURRENCY=$argv[4];
$url="http://apilayer.net/api/live?access_key=".$API_SECRET."¤cies=".$CURRENCY."&format=1";
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
$json = json_decode(curl_exec($handle), true);
if($json['success'] && $json['quotes']['USDINR']>=$threshold){
$message= "Exchange rates above ".$json['quotes']['USDINR']." INR. Consider transferring money now.";
$subject= "Favourable Exchange Rates !!";
}elseif(!$json['success'] ){
$message= "There is some issue with the Exchangor API. Please look into it";
$subject= "Issue with the Exchangor API";
}else{
return 0;
}
email_client::email_send($receiver,$message,$subject);
?>