CodeIgniter Forums
Form Data invalid when sending POST(through CURL) to Codeigniter - 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: Form Data invalid when sending POST(through CURL) to Codeigniter (/showthread.php?tid=47737)



Form Data invalid when sending POST(through CURL) to Codeigniter - El Forum - 12-20-2011

[eluser]Unknown[/eluser]
Hi there,

hopefully someone can help me.
Let me explain shortly what i want to do:
In an external Website we have a form with Post Data which we want to send through Curl to one Codeigniter Installation.

The Problem is that CI returns a 500 Error together with the message "An Error Was Encountered, The Formulardata u sent is invalid". If i change POSTFIELDS to a simple string it does work, also if i make just a testscript outside CI. So Curl seems to be fine.

Something in CI breaks up the POST array, i also tried to set the permit uri characters.. but that didnt helped ://

Attached the Curl Script and its Output. Code in CI is just a controller with a simple print of $_POST.


Would be great if someone has an idea what could be the problem..

Thanks!!!

Quote:Array
(
[url] => http://example.de/api/save_data/
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => 0
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0
[redirect_time] => 0
)



HTTP/1.1 100 Continue
HTTP/1.1 500 Internal Server Error
Date: Tue, 20 Dec 2011 16:05:27 GMT
Server: Apache
X-Powered-By: PHP/5.3.8-nmm1
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

Code:
function curl_call($url, $data, $print=true){
   $ret="";
   $ch = curl_init($url);
   curl_setopt( $ch, CURLOPT_POST, true );
   curl_setopt( $ch, CURLOPT_POSTFIELDS, array("key" => "value") );
   curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt( $ch, CURLOPT_HEADER, true);
  
   $info = curl_getinfo($ch);
   $ret = curl_exec($ch);

   curl_close($ch);
   return $ret;
  }

  $bp_tool_url = "http://example.de/api/save_data/";

  $ret = curl_call($bp_tool_url, $data);