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";
32 $doc = new DOMDocument();
33 $doc->loadHTML($response);
35 $xpath = new DOMXpath($doc);
40 // 'date1' => '10/14/14',
41 // 'date'=> '10/20/14',
42 // 'date_fmt' => 'us',
45 // 'margin_fixed' => 0,
49 // $response = $this->curl($this->actionUrl, $params, 'POST');
51 // file_put_contents('/tmp/test.html', $response);
55 function curl($url, $request = array(), $method = 'GET')
58 if(is_array($request)){
59 $request = http_build_query($request);
62 $url = $url . ($method == 'GET' ? "?" . $request : '');
63 $ch = curl_init($url);
65 if ($method == 'POST') {
66 curl_setopt($ch, CURLOPT_POST, 1);
67 curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
68 curl_setopt($ch, CURLOPT_HTTPHEADER,
69 array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($request)));
72 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
74 curl_setopt($ch, CURLOPT_HEADER, false);
75 curl_setopt($ch, CURLOPT_VERBOSE, 1);
76 curl_setopt($ch, CURLOPT_TIMEOUT, 30);
77 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
79 $response = curl_exec($ch);