cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Please help

From: Kirk Cerny <kirksemail_at_gmail.com>
Date: Thu, 30 Sep 2004 15:44:58 -0600

I am attempting to connect to a server using https:
and a session cookie. I can not seem to get in using a valid session.

I am attempting to get into a server I run, so I am able to make
changes on both machines.

This is my code

Nothing ever gets put into the cookie file, and I get a different
error number every time.

function GetCurlPage ($pageSpec)
{
   $agent = "up.b";
   $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
   $header[] = "Accept: text/vnd.wap.wml,*.*";
   $ch = curl_init($pageSpec);

   //$ch = curl_init();
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

   //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_VERBOSE, 1); ########### debug
   curl_setopt($ch, CURLOPT_USERAGENT, $agent);
   curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt($ch, CURLOPT_COOKIEJAR, "cook");
   curl_setopt($ch, CURLOPT_COOKIEFILE, "cook");

   $tmp = curl_exec ($ch);
   $ans = curl_error ($ch);
   $num = curl_errno ($ch);
   echo ("<p> ERROR: $ans : - num: $num </p>");

   curl_close ($ch);
   return $tmp;
}

function PostCurlPage ($pageSpec, $data)
{
   $agent = "up.b";
   $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
   $header[] = "Accept: text/vnd.wap.wml,*.*";
   $ch = curl_init($pageSpec);
   //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   //curl_setopt($ch, CURLOPT_VERBOSE, 1); ########### debug
   curl_setopt($ch, CURLOPT_USERAGENT, $agent);
   curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt($ch, CURLOPT_COOKIEJAR, "cook");
   curl_setopt($ch, CURLOPT_COOKIEFILE, "cook");
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

   $tmp = curl_exec ($ch);
   $ans = curl_error ($ch);
   $num = curl_errno ($ch);
   echo ("<p> ERROR: $ans : - num: $num </p>");

   curl_close ($ch);
   return $tmp;
}

$first = GetCurlPage("https://www.paypal.com/cgi-bin/phscr?cmd=login");
$exp = explode("=", $first);
$id = explode("\"", $exp[16]);

echo htmlspecialchars($first);

$second = PostCurlPage("https://www.paypal.com/cgi-bin/phscr?rs=".$id[0],
"email=EMAIL_at_HOST.COM&pass=YOUR_PP_PASS&cmd=login-submit-pass");

echo $second."\n\n";
Received on 2004-09-30