Dustin013 Posted June 6, 2008 Share Posted June 6, 2008 Basically I am trying to authenticate a session to see if a file exist on a hosting provider, and what the download link would be (www.megashares.com). I have a php script which is parsing the data fine if I save the html file to my local machine. Without logging into the site the script obviously can't parse the correct page... so here is what I have at the moment based off a tutorial I found at : http://drupal.org/node/89710. <?php $crl = curl_init(); $url2 = "http://www.megashares.com/index.php"; curl_setopt($crl, CURLOPT_URL, $url2); curl_setopt($crl, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($crl, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($crl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($crl, CURLOPT_POST, 1); // this array will hold the field names and values $postdata=array( "lc[email]"=>"[email protected]", "lc[pin]"=>"12345678", "lc[signin]"=>"Sign-In", ); // tell curl we're going to send $postdata as the POST data curl_setopt ($crl, CURLOPT_POSTFIELDS, $postdata); $result=curl_exec($crl); $headers = curl_getinfo($crl); if ($headers['url'] == $url2) { die("Cannot login to MegaShares.com!"); } ?> It simply isn't working... any suggestions or other methods? Link to comment https://forums.phpfreaks.com/topic/108939-need-help-authenticating-with-curl-and-php/ Share on other sites More sharing options...
amites Posted June 6, 2008 Share Posted June 6, 2008 what kind of error are you getting? try throwing this in there after $result=curl_exec($crl) if (curl_errno($result) != 0) //CURL error { echo "<hr><br>\n"; echo 'Errors: '.curl_errno($result).' '.curl_error($result).'<BR><BR>'; echo "<hr><br>\n"; } Link to comment https://forums.phpfreaks.com/topic/108939-need-help-authenticating-with-curl-and-php/#findComment-558919 Share on other sites More sharing options...
Dustin013 Posted June 6, 2008 Author Share Posted June 6, 2008 I brought up PHP info and Curl is enabled... curl cURL support enabled cURL Information libcurl/7.16.0 OpenSSL/0.9.8e zlib/1.2.3 Here is the code <?php $crl = curl_init(); $url2 = "http://d01.megashares.com/index.php"; curl_setopt($crl, CURLOPT_URL, $url2); curl_setopt($crl, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($crl, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($crl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($crl, CURLOPT_POST, 1); // this array will hold the field names and values $postdata=array( "lc[email]"=>"xxxxxxxx", "lc[pin]"=>"xxxxxxxx", "lc[signin]"=>"Sign-In", "lc[login]"=>"lc_login", ); // tell curl we're going to send $postdata as the POST data curl_setopt ($crl, CURLOPT_POSTFIELDS, $postdata); $result=curl_exec($crl); if (curl_errno($result) != 0) //CURL error { echo "<hr><br>\n"; echo 'Errors: '.curl_errno($result).' '.curl_error($result).'<BR><BR>'; echo "<hr><br>\n"; } $headers = curl_getinfo($crl); if ($headers['url'] == $url2) { die("Cannot login to MegaShares.com!"); } ?> I keep getting this error: Warning: curl_errno(): supplied argument is not a valid cURL handle resource in C:\Program Files\VertrigoServ\www\dailyddl\include\megasharelogin.php on line 22 Cannot login to MegaShares.com! Link to comment https://forums.phpfreaks.com/topic/108939-need-help-authenticating-with-curl-and-php/#findComment-558946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.