Delphi Idhttp的 Get 和 Post 方法

Delphi Idhttp的 Get 和 Post 方法 


procedure TForm1.FormCreate(Sender: TObject);
var
  Param: TStringList;
  RStream: TStringStream;
begin
  Param := TStringList.Create;
  RStream := TStringStream.Create('');

  // Post
  Param.Add('username=showlee000');
  Param.Add('normModPsp=********');
  Param.Add('mem_pass=true');
  IdHTTP1.Post('Http://URL',
    Param, RStream);
  memo1.Text := RStream.DataString;

  //Get
  IdHTTP1.Request.CustomHeaders.Text :=
    'Accept: image/jpeg, application/x-ms-application, ' +
    'image/gif, application/xaml+xml, image/pjpeg, ' +
    'application/x-ms-xbap, application/vnd.ms-excel, ' +
    'application/vnd.ms-powerpoint, application/msword, */*' +
    #13 + #10 + 'Referer:http://url' +
    #13 + #10 + 'Accept-Language: zh-CN' +
    #13 + #10 + 'User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; ' +
    'Windows NT 6.1; Trident/5.0)' +
    #13 + #10 + 'Accept-Encoding: gzip, deflate' +
    #13 + #10 + 'Host: ***' +
    #13 + #10 + 'Connection: Keep-Alive' +
    #13 + #10 + 'Authorization: Basic *****=';
  IdHTTP1.get('http://url');
end;




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章