post variable contents using cURL
Moderator: General Moderators
post variable contents using cURL
How do I post the contents of a variable using cURL and HTTPS POST? Thanks.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
just like you would a get variable, except instead of in the URL you set it via curl_setopt()
example: foo=bar
example: foo=bar
Unfortunately, I'm quite new to php, so I don't know how to do that either. Also, I'd like the post it to "https://testefsnet.concordebiz.com/efsnet.dll". Thanks
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
feyd | Please use
feyd | Please use
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>feyd | Please use
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]I tried the rawurlencode but it didn't change anything. Below is the code I have now, but I'm getting an error that says:
"ResponseCode=1032&ResultCode=999&ResultMessage=INVALID+CREDENTIALS"
What does this mean? Thanks
"ResponseCode=1032&ResultCode=999&ResultMessage=INVALID+CREDENTIALS"
What does this mean? Thanks
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>- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Yes, but are the credentials wrong or the submissions bad. Usually these thing, if they take POST data, want something like:
I assume that there is documentation for this thing?
Code: Select all
$params = "myXML=<?xml version=\"1.0\" encoding=\"UTF-8\"?><Request StoreID=\"xxxxx\" StoreKey=\"xxxxxxxxxxxxxxxxx\" ApplicationID=\"Test App\"><SystemCheck /></Request>";(#10850)
I contacted the people who would know, and they said that the "https://testefsnet.concordebiz.com/efsnet.dll" page was never hit, so I assume it's not a problem with the $params. And I copied the $params code directly from an example in the documentation (I just changed the values).
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Not sure what "never hit means? When I go to that URL is says:
Which makes sense. What have you tried? Have you just tried to pass it on the command line or via a test form? What exactly does the example in the manual say?
Code: Select all
ResponseCode=1030&ResultCode=999&ResultMessage=INVALID+REQUEST(#10850)
Hey, I got it working, I just had to add this line:
Thanks for the help.
Code: Select all
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));