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