As the title suggest, I'm trying to get back the content of (several) pages on a site that requires a login. This is a legitimate login and I have access to the content - nothing shady's going on.
I've searched SO and found several posters attempting the same thing - nothing I've found has helped with this specific issue.
I've tried several variations - adding various options like FOLLOWLOCATION (set to true, then tried set to false); increasing the timeout; setting both COOKIEJAR and COOKIEFILE; calling curl_close after the login, then a new curl_init after (before loading the target file); using traditional PHP methods to grab the file (file_get_contents, etc); explicitly creating the cookie file and setting it to writable; tried with and without REFERER; tried changing up the REFERER; tried both http and https protocols; tried calling curl_close once first to force the cookie to be written, then running the script block again immediately afterward; etc... No luck.
Below is a snapshot of the code being used (just trying to get one file for now).
Any suggestions would be appreciated.
$e = curl_init(); curl_setopt($e, CURLOPT_URL, 'https://www.some-site.com/login.php'); curl_setopt($e, CURLOPT_POST, 1); curl_setopt($e, CURLOPT_POSTFIELDS, 'username=bob&password=1234'); curl_setopt($e, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($e, CURLOPT_REFERER, 'https://www.some-site.com'); curl_setopt($e, CURLOPT_RETURNTRANSFER, 1); curl_exec($e); curl_setopt($e, CURLOPT_URL, 'https://www.some-site.com/posts.php?id=1'); $content = curl_exec($e); print htmlentities($content); curl_close($e);
There is no actual error - cURL is working like it should, but $content is set to the "You're not signed in... Please login now..." page.
After logging in via browser (Fx, Chrome, Safari, IE), each post can be accessed (again, through the browser) without issue.
TYIA for any suggestions - LMK if any additional info would be helpful.