I had a devil of a time figuring out how to make it work. After searching
the archives and lots of other sites I came up with the following code:
(FYI - I am using authorize.net, so some of the response parameters may be
different for you)
HTH
Bret

<?php
$data =
"formfield1_name=formfield1_value&formfield1_name=formfield1_value&"/*etc*/;
# gets static data merchant info, login, password etc
if($x_Method=="CC"){
 $data .=
"formfield3_name=formfield3_value&formfield4_name=formfield4_value"/*etc*/;
 #gets conditional values if Credit Card is selected
 }
else{
 $data .=
"formfield5_name=formfield5_value&formfield6_name=formfield6_value"/*etc*/;
  #gets conditional values if eCheck is selected
}
$ch = curl_init("https://secure.website.net/script_or_application";); // URL
of gateway for cURL to post to
 $data .=
"x_First_Name=$x_First_Name&x_Last_Name=$x_Last_Name&x_Company=$x_Company&";
 $data .=
"x_Address=$x_Address&x_City=$x_City&x_State=$x_State&x_Zip=$x_Zip&x_Phone=$
x_Phone";
 //$data = gets the rest of all form data
curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info
from response
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // use HTTP POST to send form
data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data
instead of TRUE(1)
$resp = curl_exec($ch); //execute post and get results
curl_close ($ch);
//My responses are delimited with | (pipe)
$parts = explode("|", $resp); //creates array from reponse
?>


----- Original Message -----
From: "Steve Keller" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 21, 2002 2:03 PM
Subject: [PHP] No Reply From cURL


> I apologize for being a pest about this, I'm just not getting it.
>
> I'm attempting to open a connection to NetLedger to post an XML file. I'm
> attempting this basic code, which is pretty much what I find everywhere:
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, "https://partners.netledger.com/SmbXml";);
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> curl_setopt($ch, CURLOPT_VERBOSE, 1);
> curl_setopt($ch, CURLOPT_POSTFIELDS,$postData);
>
> $result = curl_exec ($ch);
> curl_close($ch);
> echo $result;
>
> And I'm getting no result back so I can't even see what error I'm getting.
>
> I'm using PHP 4.2.3, with OpenSSL/0.9.5a and compiled as follows:
>
> './configure' '--with-apxs=/usr/local/www/bin/apxs'
> '--with-mysql=/usr/local/' '--with-gd=/usr/local/' '--with-freetype'
> '--with-imap' '--with-curl'
>
> Also, how do I include a file in the postData? Can someone point me to a
> good page about HTTP where I can read about doing that?
> --
> S. Keller
> UI Engineer
> The Health TV Channel, Inc.
> (a non - profit organization)
> 3820 Lake Otis Pkwy.
> Anchorage, AK 99508
> 907.770.6200 ext.220
> 907.336.6205 (fax)
> Email: [EMAIL PROTECTED]
> Web: www.healthtvchannel.org
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to