I've attempted before to try to log into a website with curl and then get the contents of another web page, but that didn't work since the host website keeps redirecting me after trying to access the new page, this is the HTML response I get when trying to access a page after successfully logging on:
As you can see they tried to redirect me directly instead of giving over the content of the page I wanted to access.
But whatever, if that doesn't work, I was wondering if there's some way with PHP or any other possible way to get the content of a webpage, once I'm already logged in using THEIR website. Meaning, not to log in with curl, but once I already logged in on a separate tag into their website, is there some kind of easier (or harder, as long as it works) way to get the content of a page that you can only see when logged in? Again, ideally I would just rely on the fact that the user is already logged in to the other service, and based on that fact, get the new content.
Is there any way to do this?
EDIT::
I have searched google a lot and tried this code:
<?php
?>
<html>
<head>
</head>
<body><?php
$loginUrl = 'https://www.chabadone.org/platform/login/login.asp';
$remotePageUrl = 'http://www.chabadone.org/platform/sitecontrol/admin/#page=/platform/sitecontrol/admin/calendar/month.asp';
//These are the post data username and password
$post_data = 'action=login&cookieexists=true&redirect=1&page=&partner=&email=something@gmail.com&password=something123&userid_to_cookie=1&saveID=yes';
//init curl
$ch = curl_init();
$USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
//Set the URL to work with
curl_setopt($ch, CURLOPT_USERAGENT, $USER_AGENT);
curl_setopt($ch, CURLOPT_URL, $loginUrl);
curl_setopt($ch, CURLOPT_REFERER, $loginUrl);
// ENABLE HTTP POST
curl_setopt($ch, CURLOPT_POST, 1);
//Set the post parameters
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//Handle cookies for the login
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
//Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
//not to print out the results of its query.
//Instead, it will return the results as a string return value
//from curl_exec() instead of the usual true/false.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//execute the request (the login)
$store = curl_exec($ch);
//set the URL to the protected file
curl_setopt($ch, CURLOPT_USERAGENT, $USER_AGENT);
curl_setopt($ch, CURLOPT_URL, $remotePageUrl);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//execute the request
$content = curl_exec($ch);
file_put_contents('./download.html', $content);
echo htmlentities($content);
curl_close($ch);
?>
<script>
</script>
</body>
</html>
but it still doesn't work at all, I still get the redirect text in the result: <!DOCTYPE html> <script language="JavaScript" type="text/JavaScript"> <!-- window.top.location = "/platform/sitecontrol/sitecontrol.asp?page=%2Fplatform%2Fsitecontrol%2Fadmin%2FDefault%2Easp%3F"; // --> </script>
which is attempting to redirect me,but I need to get the actualy content of the page!