Point myway balance API at transport for canberra
--- a/myway/myway_api.json.php
+++ b/myway/myway_api.json.php
@@ -33,8 +33,8 @@
}
} */
//set POST variables
-$url = 'https://www.action.act.gov.au/ARTS/use_Funcs.asp';
-//$url = 'http://localhost/myway.htm';
+$url = 'https://www.transport.act.gov.au/ARTS/use_Funcs.asp';
+//$url = 'http://localhost/myway.html';
$field_mapping = Array(
"card_number" => "SRNO",
"DOBmonth" => "month",
@@ -81,7 +81,7 @@
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_REFERER, "https://www.action.act.gov.au/ARTS/getbalance.asp");
+ curl_setopt($ch, CURLOPT_REFERER, "https://www.transport.act.gov.au/ARTS/getbalance.asp");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
//execute post
@@ -90,6 +90,39 @@
$return["error"][] = "Network error " . curl_errno($ch) . " " . curl_error($ch) . " " . $url . $fields_string;
//close connection
curl_close($ch);
+}
+
+function parseTable($table,$tableName) {
+ global $return;
+ $tableColumns = Array();
+ $tableColumnNum = 0;
+ foreach ($table->find("th") as $th) {
+ $tableColumns[$tableColumnNum] = cleanString($th->plaintext);
+ $tableColumnNum++;
+ }
+ //print_r($tableColumns);
+ $tableRowNum = 0;
+ foreach ($table->find("tr") as $tr) {
+ $tableColumnNum = 0;
+ foreach ($tr->find("td") as $td) {
+ if ($tableName == "myway_carddetails") {
+ // first table has card/cardholder details
+ $return[$tableName][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext);
+ } else {
+ // second table has transactions
+
+ if ($tableColumns[$tableColumnNum] == "TX Reference No / Type") {
+ $return[$tableName][$tableRowNum]["TX Reference No"] = substr(cleanString($td->plaintext), 0, 6);
+ $return[$tableName][$tableRowNum]["TX Type"] = substr(cleanString($td->plaintext), 7);
+ } else {
+ $return[$tableName][$tableRowNum][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext);
+ }
+ }
+ //print_r($return);
+ $tableColumnNum++;
+ }
+ $tableRowNum++;
+ }
}
if (!isset($return['error'])) {
@@ -101,43 +134,12 @@
$return['error'][] = $pageAlerts[0]->plaintext;
}
if (!isset($return['error'])) {
- $tableNum = 0;
- $tableName = Array(
- 1 => "myway_carddetails",
- 2 => "myway_transactions"
- );
- foreach ($page->find("table") as $table) {
- $tableNum++;
- $tableColumns = Array();
- $tableColumnNum = 0;
- foreach ($table->find("th") as $th) {
- $tableColumns[$tableColumnNum] = cleanString($th->plaintext);
- $tableColumnNum++;
- }
- //print_r($tableColumns);
- $tableRowNum = 0;
- foreach ($table->find("tr") as $tr) {
- $tableColumnNum = 0;
- foreach ($tr->find("td") as $td) {
- if ($tableNum == 1) {
- // first table has card/cardholder details
- $return[$tableName[$tableNum]][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext);
- } else {
- // second table has transactions
-
- if ($tableColumns[$tableColumnNum] == "TX Reference No / Type") {
- $return[$tableName[$tableNum]][$tableRowNum]["TX Reference No"] = substr(cleanString($td->plaintext), 0, 6);
- $return[$tableName[$tableNum]][$tableRowNum]["TX Type"] = substr(cleanString($td->plaintext), 7);
- } else {
- $return[$tableName[$tableNum]][$tableRowNum][$tableColumns[$tableColumnNum]] = cleanString($td->plaintext);
- }
- }
- //print_r($return);
- $tableColumnNum++;
- }
- $tableRowNum++;
- }
- }
+ $tables = $page->find(".type3");
+ parseTable($tables[0], "myway_carddetails");
+
+ $tables = $page->find(".type2");
+ parseTable($tables[0], "myway_transactions");
+
}
}
if (sizeof($return) == 0) {