Ignore:
Timestamp:
Apr 14, 2015, 10:20:16 PM (10 years ago)
Author:
chronos
Message:
  • Removed: Spaces on end of line.
  • Modified: Tabs converted to spaces.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/FinanceBankAPI/FioAPI.php

    r628 r738  
    11<?php
    2  
     2
    33// Specifikace API: http://www.fio.cz/docs/cz/API_Bankovnictvi.pdf
    44
     
    1010    else return($Text);
    1111}
    12  
     12
    1313class FioAPI
    1414{
     
    1616  var $Encoding;
    1717  var $Format;
    18  
     18
    1919  function __construct()
    2020  {
     
    2222    $this->Format = 'csv';
    2323  }
    24  
     24
    2525  function Import($TimeFrom, $TimeTo)
    2626  {
    2727    if($this->Token == '') throw new Exception('Missing value for Token property.');
    28  
     28
    2929    // URL format: https://www.fio.cz/ib_api/rest/periods/{token}/{datum od}/{datum do}/transactions.{format}
    3030    // Send request
     
    3232      date('Y-m-d', $TimeFrom).'/'.date('Y-m-d', $TimeTo).'/transactions.'.$this->Format;
    3333    $Response = file_get_contents('https://www.fio.cz'.$RequestURL);
    34     if($Response == FALSE) 
     34    if($Response == FALSE)
    3535    {
    3636      throw new Exception('Connection error');
    37     } else 
     37    } else
    3838    {
    3939      if($this->Format == 'gpc') $Response = iconv('windows-1250', $this->Encoding, $Response);
    4040      $Response = explode("\n", $Response);
    41      
     41
    4242      if($this->Format == 'gpc')
    43       {       
     43      {
    4444        // Parse all GPC lines
    4545        $GPC = new GPC();
     
    5757          'Items' => array(),
    5858        );
    59        
     59
    6060        // CVS header
    61         while($Response[0] != '') 
     61        while($Response[0] != '')
    6262        {
    6363          $Line = explode(';', $Response[0]);
    6464          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];
    6666          else if($Line[0] == 'currency') $Result['Currency'] = $Line[0];
    6767          else if($Line[0] == 'iban') $Result['IBAN'] = $Line[0];
     
    7272          else if($Line[0] == 'dateEnd') $Result['DateEnd'] = $Line[0];
    7373          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];
    7575          array_shift($Response);
    7676        }
     
    8686          $Date = explode('.', $Line[1]);
    8787          $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],
    8989            'OffsetAccount' => $Line[4], 'OffsetAccountName' => $Line[5], 'BankCode' => $Line[6], 'BankName' => RemoveComma($Line[7]),
    9090            '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]),
    9393            'BIC' => $Line[17], 'OrderID' => $Line[18]);
    94           $Result['Items'][] = $NewRecord;         
     94          $Result['Items'][] = $NewRecord;
    9595        }
    9696      }
     
    9898    }
    9999  }
    100  
     100
    101101  function NoValidDataError($Response)
    102102  {
     
    105105    $Response = implode('', $Response);
    106106    $ErrorMessageStart = '<div id="oldform_warning">';
    107     if(strpos($Response, $ErrorMessageStart) !== false) 
     107    if(strpos($Response, $ErrorMessageStart) !== false)
    108108    {
    109109      $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart));
Note: See TracChangeset for help on using the changeset viewer.