cURL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

cURL

Post 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
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post 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.
Post Reply