I few months ago, my colleague created an calendar subscription by getting the work schedule. I believe he has done this by cURL.
Now I'm building a website to have an overview about the tasks that should be done today.
I want to retrieve the schedule so I can use it to display the name of the people that are working a specific day.
I found a tutorial on the web that explains how I can get de data after a login. what I did is that I copied the name of the input fields in the login form, and the name of a hidden field named signin[_csrf_token]
with those names, I created the following code:
<?php
$username = "myusername";
$password = "mypassword";
$url = "http://planner.a-mac.nl/employeeSchedule";
$cookie= "koekje.txt";
$token = "2e4c16f2b664f3ed01827dd38dc11d22";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/'.$cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/'.$cookie);
curl_setopt($ch, CURLOPT_POSTFIELDS, "signin[username]=" . $username ."&signin[password]=" . $password . "&signin[_csrf_token]=" . $token);
//stuur de gegevens uit het formulier door naar de link
curl_exec($ch);
//Zet de output op het scherm
if (curl_errno($ch))
{
print curl_error($ch);
//Als er een fout is geef deze dan
}
else
{
curl_close($ch);
//Sluit de link met de website
}
?>
When I load my page with the above code, I get the login form with the error message:
CSRF Attack Detected
Could someone help me how to solve this problem so I can what data I got from the website?
I contacted my old colleague, but he says "he doesn't know anymore"...