0

I'm recieving data from a POST, Now I want to forward this data using curl.

The problem is that my code doesn't post special characters like ÅÄÖ. They are included in $postdata, but when I look at the receiving server, the special characters are missing.

Is there a better way to prepare the data for cUrl? Something like an prebuilt funktion? How do I include the ÅÄÖ:s?

Here is the code:

foreach ($_POST as $var => $value) {

    if ($var != "ignore") {
    $postdata=$postdata . urlencode(str_replace("_", "." , $var)) . "=" . $value . "&";
    }
}
//remove the extra comma
$postdata=substr($postdata,0,-1);

//Submit the form fields
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,$googleformURL);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$data = curl_exec ($ch);
curl_close($ch);
Himmators
  • 14,278
  • 36
  • 132
  • 223
  • Try to see http://stackoverflow.com/questions/10060093/special-characters-like-and-in-curl-post-data – Mihai8 Jan 28 '13 at 10:34
  • I don't really understand how this relays to my question: I'm pretty new to cUrl... – Himmators Jan 28 '13 at 10:38
  • Is about url encode and using unicode characters. It possible http://splunk-base.splunk.com/answers/56402/how-do-you-url-encode-a-query-you-want-to-send-to-splunk to be useful for you. – Mihai8 Jan 28 '13 at 10:43
  • What character set does the server expect, what are you sending? – Evert Jan 28 '13 at 10:51
  • @evert I started ower with a new, more specific question: http://stackoverflow.com/questions/14599548/what-text-encoding-should-i-use-for-my-curl-to-a-google-spreadsheet-form – Himmators Jan 30 '13 at 08:27

0 Answers0