DELPHI 调用淘宝API 例子

srsefr

[delphi] view plaincopy
procedureTfrmMain.btnCallTopAPIClick(Sender: TObject);  
var  
 AHttpRequestURL:String;  
 AHttpReponseContent:TMemoryStream;  
begin  
 AHttpReponseContent:=TMemoryStream.Create;  
  try  
   IdHTTP1.ReadTimeout:=0;  
   IdHTTP1.AllowCookies:=True;  
   IdHTTP1.ProxyParams.BasicAuthentication:=False;  
   IdHTTP1.ProxyParams.ProxyPort:=0;  
   IdHTTP1.Request.ContentLength:=-1;  
   IdHTTP1.Request.ContentRangeEnd:=0;  
   IdHTTP1.Request.ContentRangeStart:=0;  
   IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded';  
   IdHTTP1.Request.Accept:='text/html, */*';  
   IdHTTP1.Request.BasicAuthentication:=False;  
   IdHTTP1.Request.UserAgent:='Mozilla/3.0 (compatible; Indy Library)';  
   IdHTTP1.HTTPOptions:=[hoForceEncodeParams];  
   
   AHttpRequestURL:='http://gw.api.tbsandbox.com/router/rest?'  
          +'sign=5029C3055D51555112B60B33000122D5'  
          +'×tamp=2011-07-01+13%3A52%3A03'  
          +'&v=2.0'  
          +'&app_key=test'  
          +'&method=taobao.user.get'  
          +'&partner_id=top-apitools'  
          +'&format=json'  
          +'&nick=%E5%95%86%E5%AE%B6%E6%B5%8B%E8%AF%95%E5%B8%90%E5%8F%B717'  
          +'&fields=nick,location.state,location.city';  
   
   IdHTTP1.Get(AHttpRequestURL,AHttpReponseContent);  
   AHttpReponseContent.Position:=0;  
   Self.Memo1.Lines.LoadFromStream(AHttpReponseContent);  
 finally  
   AHttpReponseContent.Free;  
 end;  
end;

[delphi] view plaincopy
procedureTfrmMain.btnCallTopAPIClick(Sender: TObject);  
var  
 AHttpRequestURL:String;  
 AHttpReponseContent:TMemoryStream;  
begin  
 AHttpReponseContent:=TMemoryStream.Create;  
  try  
   IdHTTP1.ReadTimeout:=0;  
   IdHTTP1.AllowCookies:=True;  
   IdHTTP1.ProxyParams.BasicAuthentication:=False;  
   IdHTTP1.ProxyParams.ProxyPort:=0;  
   IdHTTP1.Request.ContentLength:=-1;  
   IdHTTP1.Request.ContentRangeEnd:=0;  
   IdHTTP1.Request.ContentRangeStart:=0;  
   IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded';  
   IdHTTP1.Request.Accept:='text/html, */*';  
   IdHTTP1.Request.BasicAuthentication:=False;  
   IdHTTP1.Request.UserAgent:='Mozilla/3.0 (compatible; Indy Library)';  
   IdHTTP1.HTTPOptions:=[hoForceEncodeParams];  
   
   AHttpRequestURL:='http://gw.api.tbsandbox.com/router/rest?'  
          +'sign=5029C3055D51555112B60B33000122D5'  
          +'×tamp=2011-07-01+13%3A52%3A03'  
          +'&v=2.0'  
          +'&app_key=test'  
          +'&method=taobao.user.get'  
          +'&partner_id=top-apitools'  
          +'&format=json'  
          +'&nick=%E5%95%86%E5%AE%B6%E6%B5%8B%E8%AF%95%E5%B8%90%E5%8F%B717'  
          +'&fields=nick,location.state,location.city';  
   
   IdHTTP1.Get(AHttpRequestURL,AHttpReponseContent);  
   AHttpReponseContent.Position:=0;  
   Self.Memo1.Lines.LoadFromStream(AHttpReponseContent);  
 finally  
   AHttpReponseContent.Free;  
 end;  
end;

[delphi] view plaincopy
procedureTfrmMain.btnCallTopAPIClick(Sender: TObject);  
var  
 AHttpRequestURL:String;  
 AHttpReponseContent:TMemoryStream;  
begin  
 AHttpReponseContent:=TMemoryStream.Create;  
  try  
   IdHTTP1.ReadTimeout:=0;  
   IdHTTP1.AllowCookies:=True;  
   IdHTTP1.ProxyParams.BasicAuthentication:=False;  
   IdHTTP1.ProxyParams.ProxyPort:=0;  
   IdHTTP1.Request.ContentLength:=-1;  
   IdHTTP1.Request.ContentRangeEnd:=0;  
   IdHTTP1.Request.ContentRangeStart:=0;  
   IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded';  
   IdHTTP1.Request.Accept:='text/html, */*';  
   IdHTTP1.Request.BasicAuthentication:=False;  
   IdHTTP1.Request.UserAgent:='Mozilla/3.0 (compatible; Indy Library)';  
   IdHTTP1.HTTPOptions:=[hoForceEncodeParams];  
   
   AHttpRequestURL:='http://gw.api.tbsandbox.com/router/rest?'  
          +'sign=5029C3055D51555112B60B33000122D5'  
          +'×tamp=2011-07-01+13%3A52%3A03'  
          +'&v=2.0'  
          +'&app_key=test'  
          +'&method=taobao.user.get'  
          +'&partner_id=top-apitools'  
          +'&format=json'  
          +'&nick=%E5%95%86%E5%AE%B6%E6%B5%8B%E8%AF%95%E5%B8%90%E5%8F%B717'  
          +'&fields=nick,location.state,location.city';  
   
   IdHTTP1.Get(AHttpRequestURL,AHttpReponseContent);  
   AHttpReponseContent.Position:=0;  
   Self.Memo1.Lines.LoadFromStream(AHttpReponseContent);  
 finally  
   AHttpReponseContent.Free;  
 end;  
end;

[delphi] view plaincopy
procedureTfrmMain.btnCallTopAPIClick(Sender: TObject);  
var  
 AHttpRequestURL:String;  
 AHttpReponseContent:TMemoryStream;  
begin  
 AHttpReponseContent:=TMemoryStream.Create;  
  try  
   IdHTTP1.ReadTimeout:=0;  
   IdHTTP1.AllowCookies:=True;  
   IdHTTP1.ProxyParams.BasicAuthentication:=False;  
   IdHTTP1.ProxyParams.ProxyPort:=0;  
   IdHTTP1.Request.ContentLength:=-1;  
   IdHTTP1.Request.ContentRangeEnd:=0;  
   IdHTTP1.Request.ContentRangeStart:=0;  
   IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded';  
   IdHTTP1.Request.Accept:='text/html, */*';  
   IdHTTP1.Request.BasicAuthentication:=False;  
   IdHTTP1.Request.UserAgent:='Mozilla/3.0 (compatible; Indy Library)';  
   IdHTTP1.HTTPOptions:=[hoForceEncodeParams];  
   
   AHttpRequestURL:='http://gw.api.tbsandbox.com/router/rest?'  
          +'sign=5029C3055D51555112B60B33000122D5'  
          +'×tamp=2011-07-01+13%3A52%3A03'  
          +'&v=2.0'  
          +'&app_key=test'  
          +'&method=taobao.user.get'  
          +'&partner_id=top-apitools'  
          +'&format=json'  
          +'&nick=%E5%95%86%E5%AE%B6%E6%B5%8B%E8%AF%95%E5%B8%90%E5%8F%B717'  
          +'&fields=nick,location.state,location.city';  
   
   IdHTTP1.Get(AHttpRequestURL,AHttpReponseContent);  
   AHttpReponseContent.Position:=0;  
   Self.Memo1.Lines.LoadFromStream(AHttpReponseContent);  
 finally  
   AHttpReponseContent.Free;  
 end;  
end;

[delphi] view plaincopy
procedureTfrmMain.btnCallTopAPIClick(Sender: TObject);  
var  
 AHttpRequestURL:String;  
 AHttpReponseContent:TMemoryStream;  
begin  
 AHttpReponseContent:=TMemoryStream.Create;  
  try  
   IdHTTP1.ReadTimeout:=0;  
   IdHTTP1.AllowCookies:=True;  
   IdHTTP1.ProxyParams.BasicAuthentication:=False;  
   IdHTTP1.ProxyParams.ProxyPort:=0;  
   IdHTTP1.Request.ContentLength:=-1;  
   IdHTTP1.Request.ContentRangeEnd:=0;  
   IdHTTP1.Request.ContentRangeStart:=0;  
   IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded';  
   IdHTTP1.Request.Accept:='text/html, */*';  
   IdHTTP1.Request.BasicAuthentication:=False;  
   IdHTTP1.Request.UserAgent:='Mozilla/3.0 (compatible; Indy Library)';  
   IdHTTP1.HTTPOptions:=[hoForceEncodeParams];  
   
   AHttpRequestURL:='http://gw.api.tbsandbox.com/router/rest?'  
          +'sign=5029C3055D51555112B60B33000122D5'  
          +'×tamp=2011-07-01+13%3A52%3A03'  
          +'&v=2.0'  
          +'&app_key=test'  
          +'&method=taobao.user.get'  
          +'&partner_id=top-apitools'  
          +'&format=json'  
          +'&nick=%E5%95%86%E5%AE%B6%E6%B5%8B%E8%AF%95%E5%B8%90%E5%8F%B717'  
          +'&fields=nick,location.state,location.city';  
   
   IdHTTP1.Get(AHttpRequestURL,AHttpReponseContent);  
   AHttpReponseContent.Position:=0;  
   Self.Memo1.Lines.LoadFromStream(AHttpReponseContent);  
 finally  
   AHttpReponseContent.Free;  
 end;  
end;

[delphi] view plaincopy
procedureTfrmMain.btnCallTopAPIClick(Sender: TObject);  
var  
 AHttpRequestURL:String;  
 AHttpReponseContent:TMemoryStream;  
begin  
 AHttpReponseContent:=TMemoryStream.Create;  
  try  
   IdHTTP1.ReadTimeout:=0;  
   IdHTTP1.AllowCookies:=True;  
   IdHTTP1.ProxyParams.BasicAuthentication:=False;  
   IdHTTP1.ProxyParams.ProxyPort:=0;  
   IdHTTP1.Request.ContentLength:=-1;  
   IdHTTP1.Request.ContentRangeEnd:=0;  
   IdHTTP1.Request.ContentRangeStart:=0;  
   IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded';  
   IdHTTP1.Request.Accept:='text/html, */*';  
   IdHTTP1.Request.BasicAuthentication:=False;  
   IdHTTP1.Request.UserAgent:='Mozilla/3.0 (compatible; Indy Library)';  
   IdHTTP1.HTTPOptions:=[hoForceEncodeParams];  
   
   AHttpRequestURL:='http://gw.api.tbsandbox.com/router/rest?'  
          +'sign=5029C3055D51555112B60B33000122D5'  
          +'×tamp=2011-07-01+13%3A52%3A03'  
          +'&v=2.0'  
          +'&app_key=test'  
          +'&method=taobao.user.get'  
          +'&partner_id=top-apitools'  
          +'&format=json'  
          +'&nick=%E5%95%86%E5%AE%B6%E6%B5%8B%E8%AF%95%E5%B8%90%E5%8F%B717'  
          +'&fields=nick,location.state,location.city';  
   
   IdHTTP1.Get(AHttpRequestURL,AHttpReponseContent);  
   AHttpReponseContent.Position:=0;  
   Self.Memo1.Lines.LoadFromStream(AHttpReponseContent);  
 finally  
   AHttpReponseContent.Free;  
 end;  
end;

[delphi] view plaincopy
procedureTfrmMain.btnCallTopAPIClick(Sender: TObject);  
var  
 AHttpRequestURL:String;  
 AHttpReponseContent:TMemoryStream;  
begin  
 AHttpReponseContent:=TMemoryStream.Create;  
  try  
   IdHTTP1.ReadTimeout:=0;  
   IdHTTP1.AllowCookies:=True;  
   IdHTTP1.ProxyParams.BasicAuthentication:=False;  
   IdHTTP1.ProxyParams.ProxyPort:=0;  
   IdHTTP1.Request.ContentLength:=-1;  
   IdHTTP1.Request.ContentRangeEnd:=0;  
   IdHTTP1.Request.ContentRangeStart:=0;  
   IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded';  
   IdHTTP1.Request.Accept:='text/html, */*';  
   IdHTTP1.Request.BasicAuthentication:=False;  
   IdHTTP1.Request.UserAgent:='Mozilla/3.0 (compatible; Indy Library)';  
   IdHTTP1.HTTPOptions:=[hoForceEncodeParams];  
   
   AHttpRequestURL:='http://gw.api.tbsandbox.com/router/rest?'  
          +'sign=5029C3055D51555112B60B33000122D5'  
          +'×tamp=2011-07-01+13%3A52%3A03'  
          +'&v=2.0'  
          +'&app_key=test'  
          +'&method=taobao.user.get'  
          +'&partner_id=top-apitools'  
          +'&format=json'  
          +'&nick=%E5%95%86%E5%AE%B6%E6%B5%8B%E8%AF%95%E5%B8%90%E5%8F%B717'  
          +'&fields=nick,location.state,location.city';  
   
   IdHTTP1.Get(AHttpRequestURL,AHttpReponseContent);  
   AHttpReponseContent.Position:=0;  
   Self.Memo1.Lines.LoadFromStream(AHttpReponseContent);  
 finally  
   AHttpReponseContent.Free;  
 end;  
end;

(0)

相关推荐