Changeset 738 for trunk/Modules/FinanceBankAPI/FioAPI.php
- Timestamp:
- Apr 14, 2015, 10:20:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/FinanceBankAPI/FioAPI.php
r628 r738 1 1 <?php 2 2 3 3 // Specifikace API: http://www.fio.cz/docs/cz/API_Bankovnictvi.pdf 4 4 … … 10 10 else return($Text); 11 11 } 12 12 13 13 class FioAPI 14 14 { … … 16 16 var $Encoding; 17 17 var $Format; 18 18 19 19 function __construct() 20 20 { … … 22 22 $this->Format = 'csv'; 23 23 } 24 24 25 25 function Import($TimeFrom, $TimeTo) 26 26 { 27 27 if($this->Token == '') throw new Exception('Missing value for Token property.'); 28 28 29 29 // URL format: https://www.fio.cz/ib_api/rest/periods/{token}/{datum od}/{datum do}/transactions.{format} 30 30 // Send request … … 32 32 date('Y-m-d', $TimeFrom).'/'.date('Y-m-d', $TimeTo).'/transactions.'.$this->Format; 33 33 $Response = file_get_contents('https://www.fio.cz'.$RequestURL); 34 if($Response == FALSE) 34 if($Response == FALSE) 35 35 { 36 36 throw new Exception('Connection error'); 37 } else 37 } else 38 38 { 39 39 if($this->Format == 'gpc') $Response = iconv('windows-1250', $this->Encoding, $Response); 40 40 $Response = explode("\n", $Response); 41 41 42 42 if($this->Format == 'gpc') 43 { 43 { 44 44 // Parse all GPC lines 45 45 $GPC = new GPC(); … … 57 57 'Items' => array(), 58 58 ); 59 59 60 60 // CVS header 61 while($Response[0] != '') 61 while($Response[0] != '') 62 62 { 63 63 $Line = explode(';', $Response[0]); 64 64 if($Line[0] == 'accountId') $Result['AccountNumber'] = $Line[0]; 65 else if($Line[0] == 'bankId') $Result['BankId'] = $Line[0]; 65 else if($Line[0] == 'bankId') $Result['BankId'] = $Line[0]; 66 66 else if($Line[0] == 'currency') $Result['Currency'] = $Line[0]; 67 67 else if($Line[0] == 'iban') $Result['IBAN'] = $Line[0]; … … 72 72 else if($Line[0] == 'dateEnd') $Result['DateEnd'] = $Line[0]; 73 73 else if($Line[0] == 'idFrom') $Result['IdFrom'] = $Line[0]; 74 else if($Line[0] == 'idTo') $Result['IdTo'] = $Line[0]; 74 else if($Line[0] == 'idTo') $Result['IdTo'] = $Line[0]; 75 75 array_shift($Response); 76 76 } … … 86 86 $Date = explode('.', $Line[1]); 87 87 $Date = mktime(0, 0, 0, $Date[1], $Date[0], $Date[2]); 88 $NewRecord = array('ID' => $Line[0], 'Date' => $Date, 'Value' => $Line[2], 'CurrencyCode' => $Line[3], 88 $NewRecord = array('ID' => $Line[0], 'Date' => $Date, 'Value' => $Line[2], 'CurrencyCode' => $Line[3], 89 89 'OffsetAccount' => $Line[4], 'OffsetAccountName' => $Line[5], 'BankCode' => $Line[6], 'BankName' => RemoveComma($Line[7]), 90 90 'ConstantSymbol' => $Line[8], 'VariableSymbol' => $Line[9], 'SpecificSymbol' => $Line[10], 91 'UserIdent' => RemoveComma($Line[11]), 'Message' => RemoveComma($Line[12]), 'Type' => RemoveComma($Line[13]), 92 'User' => RemoveComma($Line[14]), 'Details' => RemoveComma($Line[15]), 'Comment' => RemoveComma($Line[16]), 91 'UserIdent' => RemoveComma($Line[11]), 'Message' => RemoveComma($Line[12]), 'Type' => RemoveComma($Line[13]), 92 'User' => RemoveComma($Line[14]), 'Details' => RemoveComma($Line[15]), 'Comment' => RemoveComma($Line[16]), 93 93 'BIC' => $Line[17], 'OrderID' => $Line[18]); 94 $Result['Items'][] = $NewRecord; 94 $Result['Items'][] = $NewRecord; 95 95 } 96 96 } … … 98 98 } 99 99 } 100 100 101 101 function NoValidDataError($Response) 102 102 { … … 105 105 $Response = implode('', $Response); 106 106 $ErrorMessageStart = '<div id="oldform_warning">'; 107 if(strpos($Response, $ErrorMessageStart) !== false) 107 if(strpos($Response, $ErrorMessageStart) !== false) 108 108 { 109 109 $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart));
Note:
See TracChangeset
for help on using the changeset viewer.