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?
Asked
Active
Viewed 4,897 times
-1
-
use HTTP GET or HHTP POST to send parameters, then use PHP script to work it, jenerate JSON file/webpage with results and parse those results in Delphi program – Arioch 'The Oct 29 '13 at 10:30
-
So what is the API between server and client ? do you have a fixed Server APi so that you need to make Delphi client compatible ? or do you have a fixed Delphi client APi, so you need to develop a PHP server compatible ? – Arioch 'The Oct 29 '13 at 10:32
-
Thank you Mr Arioch for your reply, Sorry I am beginner in Delphi and also PHP so apologize me, I send data from delphi to php(2 digits) and multiplyed them inside php, i need now to return the result(result of multiplication) again to delphi program and print it there, how can I do this? – ayman Oct 29 '13 at 10:51
-
you have 3 questions rather than one: 1) which protocol specification you would design for server-client interactions, regarding the requirements to the task, 2) how to implement that protocol in PHP server (or non-PHP server), 3) How to implement that protocol in Delphi Client. And there are uncountable number of variants to answer all those questions. This site seldom work in "write the program for me" manner. So you better answer those questions separately. http://en.wikipedia.org/wiki/Divide_and_conquer http://stackoverflow.com/help/on-topic – Arioch 'The Oct 29 '13 at 11:01
1 Answers
1
One of straight-forward ways in REST pattern (http://en.wikipedia.org/wiki/REST) would be:
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
- 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

Community
- 1
- 1

Arioch 'The
- 15,799
- 35
- 62