How to receive data from php server by delphi clie

2019-09-20 05:34发布

问题:

Please I need to know how to send parameters from Delphi application to php page then php will make some calculations on these parameters and return result again to Delphi?

回答1:

One of straight-forward ways in REST pattern (http://en.wikipedia.org/wiki/REST) would be:

  • Getting JSON data from a website using Delphi
  • How to send/receive JSON?

1) Your Delphi client gets the page, passing all the parameters as HTTP GET or HTTP POST.

  • http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods
  • How are parameters sent in an HTTP POST request?

  • What's the simplest way to call Http GET url using Delphi?

  • What’s the simplest way to call Http POST url using Delphi?
  • Synapse Delphi HTTPS SSL GET Request

using any library you wish. Some choices (not complete list) include:

  • WinInet (Windows system library) http://msdn.microsoft.com
  • Internet Component Suite http://OverByte.be
  • Internet Direct http://indyproject.org
  • Synapse http://synapse.ararat.cz
  • URL Grabber from JediVCL http://jVCL.sf.net
  • parts of mORMot framework http://synopse.info

et cetera

2) your PHP server gets those parameters and generates JSON page with the results

  • How to generate json using php? - and all the links to manuals and tutorials there

3) your Delphi client getting the page via HTTP, then parses JSON and works with the resulting variables

Some libraries to parse JSON are

  • SuperObject Delphi / SuperObject - Accessing Subnodes and SuperObject - Extract All and other superobject questions
  • parts of mORMot framework http://synopse.info
  • Using DB Express in Delphi Enterprise https://stackoverflow.com/search?q=delphi+TJSONObject

4) do with the received data what you want to do



标签: php delphi http