Changeset 4 for trunk/UFioAPI.pas


Ignore:
Timestamp:
Mar 13, 2013, 11:29:59 PM (11 years ago)
Author:
chronos
Message:
  • Přidáno: Zkušební stažení stránky přes https.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UFioAPI.pas

    r3 r4  
    66
    77uses
    8   Classes, SysUtils;
     8  Classes, SysUtils, httpsend;
    99
    1010type
     11
     12  { TFioAPI }
     13
    1114  TFioAPI = class
    12 
     15    Token: string;
     16    Format: string;
     17    function Download: Boolean;
    1318  end;
    1419
    1520implementation
    1621
     22{ TFioAPI }
     23
     24function TFioAPI.Download: Boolean;
     25var
     26  HTTPSender: THTTPSend;
     27begin
     28  HTTPSender := THTTPSend.Create;
     29  try
     30    Format := 'xml';
     31    Token := 'dd';
     32//    HTTPSender.HTTPMethod('GET', 'https://www.fio.cz/ib_api/rest/periods/' + Token +
     33//      '/2013-03-01/2013-03-15/transactions.' + Format);
     34HTTPSender.HTTPMethod('GET', 'https://www.fio.cz/e-broker/e-broker.cgi');
     35    try
     36    case HTTPSender.Resultcode of
     37        100..299:
     38          begin
     39{            with TFileStream.Create(TargetFile, fmCreate or fmOpenWrite) do
     40            try
     41              Seek(0, soFromBeginning);
     42              CopyFrom(HTTPSender.Document, 0);
     43            finally
     44              Free;
     45            end;}
     46            Result := True;
     47          end; //informational, success
     48        300..399: Result := False; //redirection. Not implemented, but could be.
     49        400..499: Result := False; //client error; 404 not found etc
     50        500..599: Result := False; //internal server error
     51        else Result := False; //unknown code
     52      end;
     53    except
     54      // We don't care for the reason for this error; the download failed.
     55      Result := false;
     56    end;
     57  finally
     58    HTTPSender.Free;
     59  end;
     60end;
     61
    1762end.
    1863
Note: See TracChangeset for help on using the changeset viewer.