3 require_once 'Pman.php';
5 class Pman_Core_UpdateCurrencyRate extends Pman
8 static $cli_desc = "Update Currency Exchange Rate";
10 static $cli_opts = array();
14 var $actionUrl = 'http://www.oanda.com/currency/historical-rates-classic';
19 $ff = HTML_FlexyFramework::get();
20 if (!empty($ff->cli)) {
30 echo"'update currency exchange rate \n";
35 'date1' => '10/14/14',
47 $response = $this->curl($this->actionUrl, $params, 'POST');
49 file_put_contents('/tmp/test.html', $response);
53 function curl($url, $request = array(), $method = 'GET')
56 if(is_array($request)){
57 $request = http_build_query($request);
60 $url = $url . ($method == 'GET' ? "?" . $request : '');
61 $ch = curl_init($url);
63 if ($method == 'POST') {
64 curl_setopt($ch, CURLOPT_POST, 1);
65 curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
66 curl_setopt($ch, CURLOPT_HTTPHEADER,
67 array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($request)));
70 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
72 curl_setopt($ch, CURLOPT_HEADER, false);
73 curl_setopt($ch, CURLOPT_VERBOSE, 1);
74 curl_setopt($ch, CURLOPT_TIMEOUT, 30);
75 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
77 $response = curl_exec($ch);