rest - How to post JSON to PHP with curl -


I may be away from the base, but I am trying to repeat this again in the PHP framework tutorial. What I do not understand is that PHP is about interpreting my mail, it always comes in the form of an empty array.

  curl-i-x post-d {"Screencast": {"subject": "tool"}} '\ http: // localhost: 3570 / index.php / trainingServer / screencast. Jason  

(This slash does not look like a fool to me, but I executed it from windows using PHP 5.2, also tried on Linux server, Linux curl with the same version )

There should be something that I am missing because it is very simple, the post has not been explained correctly, if it does, then everything will do great work.

This is what I get back to:

 HTTP / 1.1 409 Conflict Date: Fri, 01 May 2009 22:03:00 GMT Server: Apache / 2.2.8 (Win32 ) PHP / 5.5.2 by X-Power: PHP / 5.2.6 Transfer Encoding: Selected Content-Type: Text / html; Charset = iso-8859-1 {"id": null, "subject": null, "body": null, "dataUrl": null, "dataMedium": null, "created on": null, "author": null }} 

Jordans Analysis Why $ _POST-array is not populated correctly. However, you can use

  $ data = file_get_contents ("php: // input");  

Just to remove the http and see to handle it yourself.

From the perspective of a protocol, this is actually more true because you are not actually processing HTTP Multipart form data. Also, use the Application / Jason-content-type while posting on your request.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -