5,928
社区成员




uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, IdHTTP;
////根据URl,发送Http get请求,得到NativeXml的对象用函数(访问拍拍店铺的订单xml)
procedure TForm1.Button1Click(Sender: TObject);
var IdHTTP1 :TIdHTTP; RtnStream :TMemoryStream; url :string; XmlDoc :TNativeXml;
begin
url :='http://api.paipai.com/deal/sellerSearchDealList.xhtml?accessToken=fc3b8228216463071bc3099c5883f3e4&appOAuthID'
+'=700134922&charset=utf-8&dealState=DS_WAIT_SELLER_DELIVERY&format=xml&pageIndex=1&pageSize=10&randomValue=11229'
+'&sellerUin=25594165×tamp=1374226526&uin=25594165&sign=%2FQttjMDhCFaufpB03uAUAcPLR%2F4%3D';
XmlDoc :=TNativeXml.Create(self);
IdHTTP1 :=Tidhttp.Create(nil);
try
with IdHTTP1 do begin
Request.Accept :='text/html, */*';
Request.ContentLength :=0;
Request.ContentRangeEnd :=0;
Request.ContentRangeStart :=0;
Request.UserAgent :='Mozilla/3.0 (compatible; Indy Library)';
end;
try
RtnStream :=TMemoryStream.Create;
IdHTTP1.get(url, RtnStream);
XmlDoc.LoadFromStream(RtnStream);
XmlDoc.SaveToFile('test.xml'); //输出文件为空,而浏览器地址中输入url,有返回 except
on E: Exception do begin
end;
end;
finally
idhttp1.Free; RtnStream.free;
end;
end;