To all the great PHP folks out there,
I want to automate some tasks from a site and this requires me to log in. I am pretty new to cURL and just cannot seem to get this right.
I really thing the problem is the POSTFIELDS but I just don't know. Have have use LiveHeaders and put that info but no combination seems to get me anywhere. Any help would be really appreciated. Here is the code:
<?php
/
Coded By: Chad Scira (if you remove this, you will spontainously combust)
Gives you the ability to run a full blown CURL call with just a url and an array
@var string
@var array
/
function curl_http_request ($url, $options)
{
$handle = curl_init($url);
foreach ($options as $option => $value) curl_setopt($handle, constant($option), $value);
ob_start();
$buffer = curl_exec($handle);
ob_end_clean();
curl_close($handle);
return $buffer;
}
curl_http_request('http://www.pagepluscellular.com/dealers.aspx', array(
'CURLOPT_POST' => true,
'CURLOPT_FOLLOWLOCATION' => true,
'CURLOPT_POSTFIELDS' => 'ctl02_GlobalMenu1_uxLogin_txtDealerCode=XXXXXXXXXX&ctl02_GlobalMenu1_uxLogin_txtPassword=XXXXXXXXX&ctl02_GlobalMenu1_xLogin_txtPasswordTemp=PASSWORD&ctl02_GlobalMenu1_uxLogin_btnSubmit=submit',
'CURLOPT_USERAGENT' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1',
'CURLOPT_COOKIEJAR' => 'cookie.txt',
'CURLOPT_COOKIEFILE' => 'cookie.txt'
));
$ch = curl_init('http://www.pagepluscellular.com/Dealers/My%20Account/Dealer%20Account%20Summary.aspx'); // the target
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return the page
$result = curl_exec($ch); // executing the cURL
curl_close($ch); // Closing connection
echo $result;
?>
TIA,
JD