1

I am in risk of being very criticized over this question, because it might have been answered here, but I do not know to look right for it. I tried to get an answer in Foruns, but people bother to show up and say "I don't know".

I usually use TIdHTTP to call a remote PHP script and receive some data, but only when I need to communicate with REST server inputting the data directly as a parameter.

Now I need to send some big JSON object (encoded and much more than 255 bytes) and I do not know how to do it in Delphi. I know that it should be through POST method, but how to send it from Delphi? And how to receive it in PHP, $request[]?

I also need a way to do it and then wait for an answer from the server, in form of other JSON object, encoded of course. It should be very simple. I have a DB online and I want to trade some data encrypted.

Thank you for your help!

NaN
  • 8,596
  • 20
  • 79
  • 153
  • I just answered this a few days ago: http://stackoverflow.com/questions/17897521/post-json-data-to-restful-datasnap-server-from-delphi-client/17917259#17917259 – Jan Doggen Aug 01 '13 at 19:24
  • But the content is not captured by `DataSnap` in my case, it is for P `PHP`. – NaN Aug 01 '13 at 19:53
  • @JanDoggen, I used your client code, but how to receive it in PHP, $post? – NaN Aug 01 '13 at 20:08
  • Found a not very beautiful way in http://stackoverflow.com/questions/6750222/delphi-indy-send-post-data-in-cyrillic – NaN Aug 01 '13 at 21:18

1 Answers1

2

Delphi doesn't have a library for that purpose so you will have to use one of the REST client libraries that can be found on the web.

This one should suit your needs just nicely.

Here is an easy example showing how to use it.

ciruvan
  • 5,143
  • 1
  • 26
  • 32
  • These `putParams.Add('title=Buy milk');` are going to be inserted in the final URL to be sent? – NaN Aug 05 '13 at 08:55