[eluser]Adrian Walls[/eluser]
Hi,
I am trying to post some xml to a perl script via a cURL http request. I am using Phil Sturgeon's cURL library to execute the request but am running into a few issues and have hit a brick wall. Basically when I try to run the code below
Code:
$this->_ci->load->library('curl');
$this->_ci->curl->create($this->_api_url);
$this->_ci->curl->options(
array(
CURLOPT_BUFFERSIZE => 128,
CURLOPT_HTTPHEADER => array(
'Content-Type: text/xml; charset=utf-8',
'Content-length: '.strlen($this->_xml)
)
)
);
$this->_ci->curl->http_login($this->_sub_user, $this->_sub_pass);
$post = array('myxml' => $this->_xml);
$this->_ci->curl->post($post);
$response = $this->_ci->curl->execute();
I fail to get a response back from the server. If I remove the content-type array element then I get a response back from the server but it is not a sensible response, it should be xml but its html. I'm not sure if this is down to my cURL set-up or an issue on the receiving server. The people running the other server have said it's because I must post the XML to the script as a CGI parameter named ‘myxml’ which I believe I have done. Also, I have set the content type as text/xml but in the info array returned back from Phil's library it has set:
Code:
content_type = text/html; charset=ISO-8859-1
which doesn't seem right to me. Am fairly new to the world of cURL so I may be missing something obvious or if it's a few issues wrapped up in one.
Cheers,
Adrian