Page 1 of 1

cURL

Posted: Mon Oct 17, 2005 4:12 pm
by shiznatix
woot my first expierence with cURL and its a lot crazier than i thought. i think i have sucessfully logged into a website using this:

Code: Select all

$url = 'WEBSITE';
$ch = curl_init();   
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "uname=USERNAME&pw=PASSWORD");
curl_exec ($ch);
questions!
1) How do i then follow it to the page that it would go to and echo that page out?
2) How would i navigate to another page and echo that fun stuff out?

no further questions

edit:

never mind i have no idea what i am doing. i even tried using fsockopen and i am getting nothing returned but no errors either. this is teh fsockopen script i am trying

Code: Select all

$site = "members.cj.com";
$url = "/member/foundation/memberlogin.do";

$req = "uname=someone@somewhere.ext&pw=password";

$header = "POST $url HTTPS/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= 'Content-Length: ' . strlen($req) . "\r\n\r\n";

$fp = fsockopen ($site, 443, $errno, $errstr, 30);

if (!$fp)
  die("I couldn't connect to $site");

fputs ($fp, $header);
                
while ( !feof($fp) )
  $response[] = fread($fp, 1024);

dump($response);//printr and whatnot the array
this returns nothing but 2 empty elements. keep in mind i am trying to login to a https site. help please...


feyd | removed username and password

Posted: Mon Oct 17, 2005 5:53 pm
by Buddha443556
First, you might want to edit your email address (not mention the password) out of your post.
From the Manual:

As of PHP 4.3.0, if you have compiled in OpenSSL support, you may prefix the hostname with either 'ssl://' or 'tls://' to use an SSL or TLS client connection over TCP/IP to connect to the remote host.