Jump to content

curl problem


Recommended Posts

Hi guys. i want to use curl to authenticate to rapishare. I have set up libcurl.

 

<?php

// FIND BOOKS ON PHP AND MYSQL ON AMAZON

$url = "https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi";

$ch = curl_init();    // initialize curl handle

curl_setopt($ch, CURLOPT_URL,$url); // set url to post to

curl_setopt($ch, CURLOPT_FAILONERROR, 1);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable

curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);  // this line makes it work under https

curl_setopt($ch, CURLOPT_CAFILE, '/ca-bundle.crt')

curl_setopt($ch, CURLOPT_POST, 1); // set POST method

curl_setopt($ch, CURLOPT_POSTFIELDS, "login=testing&password=hello"); // add POST fields

$result = curl_exec($ch); // run the whole process

curl_close($ch);

echo $result;

?>

 

 

that is the code i'm using. Why do i get blank page with this? Rapidshare requires HTTPS authentication. Can someone help me out here?

Link to comment
https://forums.phpfreaks.com/topic/50367-curl-problem/
Share on other sites

Im not sure on how you are using this

curl_setopt($ch, CURLOPT_POSTFIELDS, "login=testing&password=hello"); // add POST fields

I think it should be

    // this array will hold the field names and values
   $postdata=array(
     "var1"=>"val1", 
     "var2"=>"val2",
     "var3"=>"val3", 
   );
   // tell curl we're going to send $postdata as the POST data
   curl_setopt ($crl, CURLOPT_POSTFIELDS, $postdata);

Link to comment
https://forums.phpfreaks.com/topic/50367-curl-problem/#findComment-247473
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.