curl-and-php
Regarding PHP curl posting XML files
Date: Tue, 19 Apr 2005 15:17:23 +0100
Hi,
I want to post an XML file containg some information to inland revenue website.
Iam using PHP and on an Apache web server.It took a lot of time to
setup, which I finally managed to do.
Now I have the following message when I try to get the posting of XML file
"SSL certificate problem, verify that the CA cert is OK"
I have download the Open SSL etc, my guess is that I can turn off
client authentication somehow and this can help me post the file.
The follwing is the php code
<?php
$url = "https://www.tpvstest.co.uk";
$page = "/EOY/post.slt";
$post_string = "<YourXML>All XML stuff Here</YourXML>";
$header = "POST ".$page." HTTP/1.0 \r\n";
$header .= "MIME-Version: 1.0 \r\n";
$header .= "Content-type: application/PTI26 \r\n";
$header .= "Content-length: ".strlen($post_string)." \r\n";
$header .= "Content-transfer-encoding: text \r\n";
$header .= "Request-number: 1 \r\n";
$header .= "Document-type: Request \r\n";
$header .= "Interface-Version: Test 1.4 \r\n";
$header .= "Connection: close \r\n\r\n";
$header .= $post_string;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
$data = curl_exec($ch); if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
}
// use XML Parser on $data, and your set!
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE,1);
xml_parse_into_struct($xml_parser, $data, $vals, $index);
xml_parser_free($xml_parser);
// $vals = array of XML tags. Go get em!
?>
Any help to fix this problem will be greatly appreciated
Thanks
Roshan
Received on 2005-04-19