post variable contents using cURL
Posted: Mon Apr 24, 2006 4:34 pm
How do I post the contents of a variable using cURL and HTTPS POST? Thanks.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Here's the code I have. Could you tell me whats wrong? Thanks.Code: Select all
<?php
function test(){
$url = "https://www.testefsnet.concordebiz.com/efsnet.dll";
$params = "<Request StoreID=\"xxxxxxxx\" StoreKey=\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"
ApplicationID=\"Test App\">
<SystemCheck />
</Request>";
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
curl_close ($ch);
}
?>
<html>
<head>
<title>Test EFSNet Payment</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="<?php test(); ?>">
<input type="submit" name="Submit" value="Test">
</form>
<?php echo $output; ?>
</body>
</html>Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<?php
$url = "https://testefsnet.concordebiz.com/efsnet.dll";
$params = "<Request StoreID=\"xxxxx\" StoreKey=\"xxxxxxxxxxxxxxxxx\" ApplicationID=\"Test App\"><SystemCheck /></Request>";
$user_agent = $_SERVER['HTTP_USER_AGENT']." via testpostvars.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$output = curl_exec ($ch);
curl_close ($ch);
?>
<html>
<head>
<title>Test EFSNet Payment</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php echo $output; ?>
</body>
</html>Code: Select all
$params = "myXML=<?xml version=\"1.0\" encoding=\"UTF-8\"?><Request StoreID=\"xxxxx\" StoreKey=\"xxxxxxxxxxxxxxxxx\" ApplicationID=\"Test App\"><SystemCheck /></Request>";Code: Select all
ResponseCode=1030&ResultCode=999&ResultMessage=INVALID+REQUESTCode: Select all
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));