I need help with PHP, cURL, and POST

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am an experienced programmer who is just learning php and curl.

I have tried for several days to figure out how to use curl with POST
to get history information from e-gold.

The following script, which I guess uses GET works when XXXX YYYY ZZZZ have 
appropriate stuff in them.

But no matter what I have tried, and whose examples I have followed
I cannot get this to work with CURLOPT_POST set to true with what I think 
is the appropriate information supplied.

I am testing this from XAMPP 1.5.5 on a Windows XP system, and the SSL 
stuff and everything I think I need is present and seems to be working fine.

The commented out form also works, so I guess e-gold will accept POSTed data.

I just do not know how to get curl to send it for me or what options I
need to make it work.

Would someone be interested in showing me exactly what I need to modify this 
script to work with POST?

<?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";

$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);
?>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux