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',
44 $response = $this->curl($this->actionUrl, $params, 'POST');
46 file_put_contents('/tmp/test.html', $response);
50 function curl($url, $request = array(), $method = 'GET')
53 if(is_array($request)){
54 $request = http_build_query($request);
57 $url = $url . ($method == 'GET' ? "?" . $request : '');
58 $ch = curl_init($url);
60 if ($method == 'POST') {
61 curl_setopt($ch, CURLOPT_POST, 1);
62 curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
63 curl_setopt($ch, CURLOPT_HTTPHEADER,
64 array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($request)));
67 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
69 curl_setopt($ch, CURLOPT_HEADER, false);
70 curl_setopt($ch, CURLOPT_VERBOSE, 1);
71 curl_setopt($ch, CURLOPT_TIMEOUT, 30);
72 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
74 $response = curl_exec($ch);