I'm trying to connect to my school's portal using PHP Curl but having no luck because it seems to redirect to certain pages. I am making an webapp for showing the school schedule in jQuery mobile but in order to show your own schedule you need to log in and go to your schedule from there. This is what I intend to achieve using CURL with PHP.
I have used the tutorial from http://codeaid.net/php/get-the-last-effective-url-from-a-series-of-redirects-for-the-given-url which works with the given links, but I cannot find out which link I should use to redirect to my schools portal.
If anyone has an idea which steps to follow to know which URL you have to use that would be very helpful.
The code I've used:
<?php function getLastEffectiveUrl($url)
{
// initialize cURL
$curl = curl_init($url);
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
));
// execute the request
$result = curl_exec($curl);
// fail if the request was not successful
if ($result === false) {
curl_close($curl);
return null;
}
// extract the target url
$redirectUrl = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
curl_close($curl);
return $redirectUrl;
}
$lastEffectiveUrl = getLastEffectiveUrl('https://login.hhs.nl');
echo $lastEffectiveUrl . "-";
?>
Again this is a tutorial I've followed from Codeaid and I take no credit for making this myself.
The link to my schools page is https:// portal.hhs.nl and as you can see if you go there it redirects me to another page.