Problem
I want to be able to login to my account, retrieve a value from a website while logged into my account, and then print it to a web page. In particular, I want to retrieve the number of problems I have solved from Project Euler and then print it to my website.
Now, I know how to retrieve a value from a particular web page.
My Code
Disclaimer: code taken and adapted from: get value from external webpage (php or java)
I have the following code to retrieve the next value I want from a web page:
<?php
// Read the whole file.
$lines = file('https://projecteuler.net/progress');
// Go through every line ..
while ($line = array_shift($lines)) {
// Stop when you find the label we're looking for.
//NOTE: The word 'Solved' only exists on the web page when you are logged into an account.
if (strpos($line, 'Solved') !== false) break;
}
// The next line has your value on it.
$line = array_shift($lines);
// Print the first word on the line.
$values = explode(' ', $line);
echo $values[0];
?>
What this Code Actually Does
This code will go to the web page https://projecteuler.net/progress as it states. However, since this web page can be accessed without logging into the account, it will retrieve the values from that web page, instead of the web page that is accessed from logging in.
Essentially, there are two /progress pages - one for when you login, and one for when you are not logged in.
I want to be able to access the /progress page for when you are logged into your account. I have tried:
Things I've tried
I tried to use the information at this link: Reading information from a password protected site
With no success.
How might I do this?