Reading a cURL post request. |
[eluser]panos konstantinides[/eluser]
Hello I am trying to send a POST request from one CI project to another. I have written some code that sends a POST request with cURL. I have put a proxy in the middle and I can see the POST (with the HTTP parameters passed fine) request getting through fine. But on the second project I try to read the POST variable by first checking if there is a post Code: public function mymethod() but it always returns "NOT POST". In the first project I send a request by doing Code: $header[] = 'Content-type: text/plain'; Is there something I am missing? I'd appreciate any help. Regards Panos Ps. I know there are a couple of cURL libraries I can use, but I would like to use my own code.
[eluser]Jeremy Gimbel - Conflux Group[/eluser]
That's exactly what it should be doing. ![]() You see, CodeIgniter clears out the $_GET and $_POST arrays after it gathers the values and sanitizes them. It's part of it's beauty. The $_POST array is available to you to use through the Input Class in the User Guide. Try: Code: $this->input->post('fieldname'); You'll find it works quite nicely. You can simply check against that to see if a value's been sent. No need to check for value and ISSET(), as the class does that for you. Good luck with you project!
[eluser]panos konstantinides[/eluser]
Hello jeremygimbel, thanks for your reply. Unfortunatelly even if I do Code: echo $this->input->post('comment'); this returns nothing back. It behaves like the parameter is not set at all. Any other ideas? There must be something that I'm missing. Regards Panos
[eluser]panos konstantinides[/eluser]
After some trial and error attempts I found the problem. The content type should have been form-urlencoded Code: Content-type: application/x-www-form-urlencoded |
Welcome Guest, Not a member yet? Register Sign In |