Re: I need help with PHP, cURL, and POST

From: Date: Tue, 02 Jan 2007 22:50:00 +0000
Subject: Re: I need help with PHP, cURL, and POST
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-246386@lists.php.net to get a copy of this message
Charley wrote: > I am an experienced programmer who is just learning php and curl. > ... > > Would someone be interested in showing me exactly what I need to modify this > script to work with POST? the interest is 10%/week ;-) ... read on ... > > <?php > session_start(); > /***** > <form > action="https://www.e-gold.com/acct/historycsv.asp" > method="post"> > <input type="hidden" name="AccountID" value="XXXXXX"> > <input type="hidden" name="PassPhrase" > value="YYYYYYYYYYYYYYY"> > <input type="hidden" name="startmonth" value="12"> > <input type="hidden" name="startday" value="1"> > <input type="hidden" name="startyear" value="2006"> > <input type="hidden" name="endmonth" value="12"> > <input type="hidden" name="endday" value="31"> > <input type="hidden" name="endyear" value="2006"> > <input type="hidden" name="paymentsreceived" value="1"> > <input type="hidden" name="fees" value="1"> > <input type="submit" value="Submit"> > *****/ > > $pf = "AccountID=XXXXXX"; > $pf .= "&PassPhrase=YYYYYYYYYYYYYYY"; > $pf .= "&startmonth=12"; > $pf .= "&startday=1"; > $pf .= "&startyear=2006"; > $pf .= "&endmonth=12"; > $pf .= "&endday=31"; > $pf .= "&endyear=2006"; > $pf .= "&paymentsreceived=1"; > $pf .= "&fees=1"; > $pf .= "&paymentidfilter=ZZZZZZZZZZZZZZZZ"; > you don't want/need the GET query in $pf ... instead something like this needs to be used (AFAIK): curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'AccountID' => 'XXXXX', 'PassPhrase' => 'XXXXXX', /* etc, etc */ )); refer to http://php.net/curl for more info. this assumes that e-gold does accept POST as a request method (which you test form seems to indicate it does) > $ch = curl_init(); > > // Follow any Location headers > curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); > $url='https://www.e-gold.com/acct/historycsv.asp?' . > $pf; > curl_setopt($ch, CURLOPT_URL, $url); > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > > curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); > curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); > curl_setopt($ch, CURLOPT_HEADER, FALSE); > > $data=curl_exec($ch); > $info=curl_getinfo($ch); > echo "<p>curlerror=" . curl_error($ch); > curl_close($ch); > echo "<p>data="; > var_dump($data); > echo "<p>info="; > var_dump($info); > ?> >

« previous php.general (#246386) next »