Jump to content

msd

Members
  • Content Count

    79
  • Joined

  • Last visited

Everything posted by msd

  1. Hello Developers. I have one simple but not so simple in programming way of thinking request. I need to set up some applications with web service for prepaid ticketing sales. For example, a customer buys a ticket for some services and that ticket is inactive at that moment. After few days customer wants to activate this ticket and use the service that was subject of that ticket (for example, the ticket offers 3 days of free gaming in the gaming center with 5 locations). And after he activates his ticket web server needs to know which ticket was activated and to tell all other clients with some event which will be recognized by all clients at the moment of activating that that ticket is active for 3 days from today at some time. I plan to build web service which will be the center point of the app, and when operator sells ticket web service register customer data and with some event, which is listened by all Delphi App clients mark that ticket as available for activating on the any Delphi client app. After activating the Delphi app send the number, date, and time of the activated ticket to web service and web service with some event tell all clients that data. I know that this was simple every time users want to use a ticket Delphi app can contact web service, but users need an offline security system, so every client must know everything about tickets... Scenario: User buy a ticket at gaming location 3, operator fill form and with API mark ticket as sold on the web app, user want to activate this ticket after one week in the gaming location 5, user read QR code and send activating request by API to the web app and the main point of this flow is that at this moment web app fire some event which will be available for all Delphi app to mark time and date of the activated ticket in local DB. I need some expert advice 🙂 Thanks for all advice, assistance, and help in the advance...
  2. Hello developers, I need small expert assistance for translating old TIdHTTP requests to new TNetHTTPRequest. I have one function for Get and one function for Post, but credentials in the header do not have the same logic, and if someone can translate it to a new TNetHTTPRequest way of web service connection? function appGetData(API): boolean; var Url: string; lHTTP: TIdHTTP; xml: IXMLDocument; XmlRS, HttpRS, HttpRC: string; begin HttpRC := ''; HttpRS := ''; if Port = '' then Url := dm.apiHttp + '://' + dm.Server + '/api' + API else Url := dm.apiHttp + '://' + dm.Server + ':' + dm.Port + '/api' + API; try lHTTP := TIdHTTP.Create; try lHTTP.Request.Clear; lHTTP.Request.BasicAuthentication := true; lHTTP.Request.Accept := 'application/xml'; lHTTP.Request.UserName := dm.UserName; lHTTP.Request.Password := dm.Password; lHTTP.Request.ContentEncoding := 'utf-8'; lHTTP.Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)'; lHTTP.Request.CustomHeaders.AddValue('OrganisationId', dm.Company); lHTTP.Request.CustomHeaders.AddValue('Accept', 'application/xml'); lHTTP.HTTPOptions := [hoForceEncodeParams]; XmlRS := lHTTP.Get(Url); HttpRC := IntToStr(lHTTP.ResponseCode); HttpRS := lHTTP.ResponseText; except end; lHTTP.Free; if HttpRC = '200' then Result := true else Result := false; finally end; end; function PostData(API, xml: string): boolean; var Url: string; lHTTP: TIdHTTP; XmlData: TStringStream; XmlRS, HttpRS, HttpRC: string; begin HttpRC := ''; HttpRS := ''; XmlData := TStringStream.Create(xml); if Port = '' then Url := dm.apiHttp + '://' + Server + '/api' + API else Url := dm.apiHttp + '://' + Server + ':' + Port + '/api' + API; try lHTTP := TIdHTTP.Create; try lHTTP.Request.Clear; lHTTP.Request.BasicAuthentication := true; lHTTP.Request.Accept := 'application/xml'; lHTTP.Request.ContentType := 'application/xml'; lHTTP.Request.UserName := dm.UserName; lHTTP.Request.Password := dm.Password; lHTTP.Request.ContentEncoding := 'utf-8'; lHTTP.Request.UserAgent := 'Mozilla/3.0 (compatible; Indy Library)'; lHTTP.Request.CustomHeaders.AddValue('OrganisationId', dm.Company); lHTTP.Request.CustomHeaders.AddValue('Accept', 'application/xml'); lHTTP.HTTPOptions := [hoForceEncodeParams]; XmlRS := lHTTP.Post(Url, XmlData); HttpRC := IntToStr(lHTTP.ResponseCode); HttpRS := lHTTP.ResponseText; except end; XmlData.Free; lHTTP.Free; if HttpRC = '200' then Result := true else Result := false; finally end; end; Thanks for any help in the advance :-)
  3. Hello Amit, It works fine, thank you for a assistance :-)
  4. Hello Remy, I need some code rewritten to use HTTPClient & HTTPRequest instead of IdHTTP. Just someone need to translate my code (my functions) if he has some minutes free 🙂
×