unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,IdHTTP,IdMultipartFormData, aes,DateUtils;
type
TForm1 = class(TForm)
Button1: TButton;
inv: TMemo;
dec: TMemo;
mem: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
fhttpRequest: TIdHTTP;
PostData : TStringStream;
tmpStr : String;
begin
fhttpRequest := TIdHTTP.Create(nil);
fhttpRequest.HandleRedirects := True;//允许头转向
fhttpRequest.ReadTimeout := 5000;//请求超时设置
fhttpRequest.Request.ContentType := ‘application/x-www-form-urlencoded’;//设置内容类型为json
PostData := TStringStream.Create(”);
//PostData.Position := 0;//将流位置置为0
PostData.WriteString(‘appId=xxxxxxxx);
PostData.WriteString(‘appSecret=xxxxxxxxxxxxxxxxx’);
tmpStr := fhttpRequest.Post(‘http://xxxxxxxxx.com/third/token’,PostData); //tmpStr是提交后返回的数据
fhttpRequest.free;
PostData.Free;
showmessage(UTF8ToAnsi(tmpStr));
end;
end.
本文为原创文章,转载请注明出处!