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

curl-and-php

curllib and custom headers

From: Lez Lytollis <lez.lytollis_at_ntlworld.com>
Date: Tue, 13 Aug 2002 15:40:41 +0100

Hi All,

Just joined the list. I am trying to post over HTTPS to an xml api that
requires two custom headers:

the second - the session certificate - has values:
dev_name;app_name;cert_name required in that format - no embedded spaces,
separated by semi-colons. However, I keep getting an error-code back stating
that the session certificate was not in the HTTP Headers.

Any clues to what's wrong greatly appreciated.

The code I am using is:

<pre>
$data = "<?xml version='1.0'
encoding='iso-8859-1'?><request><RequestUserId>myUserID</RequestUserId>";

$data .=
"<RequestPassword>myPass</RequestPassword><ErrorLevel>1</ErrorLevel><DetailL
evel>0</DetailLevel>";

$data .= "<Verb>ValidateTestUser</Verb></request>";

$arrHeaders[0] = "CUSTOM-HEADER1: 245";

$arrHeaders[1] = "CUSTOM-HEADER2: dev_name;app_name;cert_name";

$host = "https://api-test.thehost.com";

$path = "/cgi-bin/api.dll";

$req = "POST $path HTTP/1.0\n";

$req .= "Host: $host\n";

$req .= "Content-type: application/x-www-form-urlencoded\n";

$req .= "Content-length: " . strlen($data) . "\n";

$req .= "Connection: close\n\n";

$req .= $data;

$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTPHEADER, $arrHeaders);

curl_setopt($ch, CURLOPT_URL, $host);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $req);

$response = curl_exec($ch);

curl_close($ch);

echo $response;

</pre>

TIA

Lez

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 02/08/2002
-------------------------------------------------------
This sf.net email is sponsored by: Dice - The leading online job board
for high-tech professionals. Search and apply for tech jobs today!
http://seeker.dice.com/seeker.epl?rel_code=31
Received on 2002-08-13