Changeset 4 for trunk


Ignore:
Timestamp:
Mar 13, 2013, 11:29:59 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Zkušební stažení stránky přes https.
Location:
trunk
Files:
10 added
3 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
  • trunk/UFormMain.lfm

    r3 r4  
    1010  object LabeledEdit1: TLabeledEdit
    1111    Left = 8
    12     Height = 21
     12    Height = 27
    1313    Top = 25
    1414    Width = 488
     
    1818    EditLabel.AnchorSideBottom.Control = LabeledEdit1
    1919    EditLabel.Left = 8
    20     EditLabel.Height = 13
    21     EditLabel.Top = 9
     20    EditLabel.Height = 17
     21    EditLabel.Top = 5
    2222    EditLabel.Width = 488
    2323    EditLabel.Caption = 'Token'
    2424    EditLabel.ParentColor = False
    2525    TabOrder = 0
     26  end
     27  object Button1: TButton
     28    Left = 56
     29    Height = 25
     30    Top = 184
     31    Width = 112
     32    Action = ADownload
     33    TabOrder = 1
    2634  end
    2735  object TrayIcon1: TTrayIcon
     
    43314339  object ActionList1: TActionList
    43324340    Images = ImageList1
    4333     left = 262
     4341    left = 264
    43344342    top = 93
    43354343    object AShow: TAction
     
    43414349      OnExecute = AExitExecute
    43424350    end
     4351    object ADownload: TAction
     4352      Caption = 'Zkontrolovat'
     4353      OnExecute = ADownloadExecute
     4354    end
    43434355  end
    43444356  object ImageList1: TImageList
  • trunk/UFormMain.pas

    r3 r4  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ExtCtrls, Menus, ActnList;
     9  ExtCtrls, Menus, ActnList, httpsend, UFioAPI;
    1010
    1111type
     
    1414
    1515  TFormMain = class(TForm)
     16    ADownload: TAction;
    1617    AExit: TAction;
    1718    AShow: TAction;
    1819    ActionList1: TActionList;
     20    Button1: TButton;
    1921    ImageList1: TImageList;
    2022    LabeledEdit1: TLabeledEdit;
     
    2325    PopupMenuTray: TPopupMenu;
    2426    TrayIcon1: TTrayIcon;
     27    procedure ADownloadExecute(Sender: TObject);
    2528    procedure AExitExecute(Sender: TObject);
    2629    procedure AShowExecute(Sender: TObject);
     
    5053end;
    5154
     55procedure TFormMain.ADownloadExecute(Sender: TObject);
     56var
     57  FioAPI: TFioAPI;
     58begin
     59  FioAPI := TFioAPI.Create;
     60  try
     61    FioAPI.Download;
     62  finally
     63    FioAPI.Free;
     64  end;
     65end;
     66
    5267end.
    5368
Note: See TracChangeset for help on using the changeset viewer.