cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: curl and xml problem

From: Richard Lynch <ceo_at_l-i-e.com>
Date: Thu, 27 Mar 2008 20:06:49 -0500 (CDT)

On Tue, March 18, 2008 3:58 pm, Daniel Stenberg wrote:
> On Tue, 18 Mar 2008, Michael Horowitz wrote:
>
>> Here is the code I am using. I am sending a string.
>
>> curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlResult);
>
> This this sends the data as a regular POST...
>
>> The xml shows up after it is posted as array(1) {
>> ["<?xml_version"]=>
>> string(972) "\"1.0\"?>
>
> ... and this weird splitting up the received data in "var=data" pairs
> is done
> by the receiving end => PHP code => stuff I know next to nothing
> about.

PHP expects the POST data to be, like, you know, regular POST data.

x=5&y=7

I also allows a rather nifty feature of passing in arrays:
x[0]=4&x[1]=8
results in:
array(0=>4, 1=>8)

If you send it raw XML, it's going to try and "parse" it as a POST body.

You can, however, access the "raw post data" if you turn that option
"on" in php.ini
always_populate_raw_post_data = 1
http://us3.php.net/manual/en/ini.core.php

You would then read stdin like this:
$stdin = fopen('php://stdin', 'r') or die("Can't read stdin?!");
$xml = fread($stdin, 100000000); //or loop or...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-03-28