![]() |
Reading a cURL post request. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Reading a cURL post request. (/showthread.php?tid=25091) |
Reading a cURL post request. - El Forum - 11-30-2009 [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. Reading a cURL post request. - El Forum - 11-30-2009 [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! Reading a cURL post request. - El Forum - 12-01-2009 [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 Reading a cURL post request. - El Forum - 12-01-2009 [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 |