curl problem, sending xml and values in the same post reques
Posted: Sat Oct 11, 2008 12:41 pm
Hello!
Im new to cURL and i have problem understanding it. I'm trying to make a post request to remote server using curl.
The data, what im sending is a content of a xml and other values. But the expected result is all wrong (wrong - indicates to incorrect input data). Im pretty sure that the data Im trying to send is correct (maybe curl just translates xml incorrectly or something).
I made a little html test form and tested it out (Works, im getting the result im expecting).
Help needed.
Here is the code:
Im new to cURL and i have problem understanding it. I'm trying to make a post request to remote server using curl.
The data, what im sending is a content of a xml and other values. But the expected result is all wrong (wrong - indicates to incorrect input data). Im pretty sure that the data Im trying to send is correct (maybe curl just translates xml incorrectly or something).
I made a little html test form and tested it out (Works, im getting the result im expecting).
Help needed.
Here is the code:
Code: Select all
<?php
define('URL_CLASS',http://www.domain.com/XML.asp?');
define('XML_CLASS', 'Name=Value1&Lastname=value2&XML=<?xml version="1.0" encoding="Windows-1257" ?><field>Value12</field>');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, URL_CLASS);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, XML_CLASS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data=curl_exec($ch);
curl_close ($ch);
echo $data;
?>