glenelkins Posted January 18, 2010 Share Posted January 18, 2010 Hi I have come accross the following code that allows me to grab a web page of a site that requires login first. Though it doesnt seem to submit the login form or return any session details: <?php ini_set ( 'safe_mode', '0' ); $_loginUrl = 'http://loginurl/'; $_loginFields = array ( 'username' => 'username', 'password' => 'password' ); $_remotePageUrl = 'http://pageafterlogin/'; $_login = getUrl ( $_loginUrl, 'post', $_loginFields ); $_remotePage = getUrl ( $_remotePageUrl ); echo $_login; echo $_remotePage; function getUrl ( $url, $method='', $vars = '' ) { $ch = curl_init(); if ( $method = 'post' ) { curl_setopt ( $ch, CURLOPT_POST, 1 ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $vars ); } curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 ); curl_setopt ( $ch, CURLOPT_COOKIEJAR, 'cookies/cookies.txt' ); curl_setopt ( $ch, CURLOPT_COOKIEFILE, 'cookies/cookies.txt' ); $buffer = curl_exec ( $ch ); curl_close ($ch ); return $buffer; } ?> I can't actually see anything wrong with it Quote Link to comment Share on other sites More sharing options...
trq Posted January 18, 2010 Share Posted January 18, 2010 Your question being? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.