trouble with cURL & Linkpoint
| From: | Doug Parker | Date: | Sun, 23 Mar 2003 16:08:20 +0000 |
| Subject: | trouble with cURL & Linkpoint | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-140761@lists.php.net to get a copy of this message | ||
I'm having trouble getting cURL to work with a remote server. I'm using Linkpoint to process a credit card transaction. (Does anyone have any experience with Linkpoint?) I have tested my script on another server and cURL seems to retrieve the information fine. However, I'm getting a blank html page when I try the linkpoint form processor. When I submitted the form directly to Linkpoint, everything worked OK.
Here's the script I submit to on my server:
$postfields = array();
$postfields[] = array("bname", $_POST['bname']);
$postfields[] = array("baddr1", $_POST['baddr1']);
$postfields[] = array("baddr2", $_POST['baddr2']);
$postfields[] = array("bcity", $_POST['bcity']);
$postfields[] = array("bstate", $_POST['bstate']);
$postfields[] = array("bzip", $_POST['bzip']);
foreach($postfields as $subarray) {
list($foo, $bar) = $subarray;
$bar = urlencode($bar);
$postedfields[] = "$foo=$bar";
}
$urlstring = join("\n", $postedfields);
$urlstring = ereg_replace("\n", "&", $urlstring);
$ch = curl_init("https://www.linkpointcentral.com/lpc/servlet/lppay");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $urlstring);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_REFERER, "http://www.mysite.com/mypage.html");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;