[FireMonkey]用IdHTTP发送Rest API

procedure TForm1.Button1Click(Sender: TObject);
var
  response : string;
  JSONToSend: TStringStream;
begin
  JSONToSend := TStringStream.Create('{}');
  IdHTTP1.Request.Connection := 'Keep-Alive';
  //IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method := sslvSSLv23;
  IdHTTP1.Request.CustomHeaders.Clear;
  IdHTTP1.Request.CustomHeaders.Values['Application-Id'] := 'yourAppId';
  IdHTTP1.Request.CustomHeaders.Values['REST-API-Key'] := 'yourRESTAPIKey';
  IdHTTP1.Request.ContentType := 'application/json';
  response := IdHttp1.Post('https://api.xxx.com/1/events/AppOpened', JSONToSend);
end;
posted on 2016-02-02 14:26  蓝懒虫  阅读(264)  评论(0编辑  收藏  举报