Hemmersbach engineers need to log into a portal to state their “at work”.
Save this script and run it as a cron job to perform the task automatically .
<?php
$link = “[place your https://mystatus.hemmersbach.com/index.php?token=XXX here with the quotes]”;
$queryString = parse_url($link, PHP_URL_QUERY);
// Parse the query string to get individual parameters
parse_str($queryString, $params);
if (!isset($params[‘token’])) {
header(“Location: error.php”);
exit();
} else {
$token = $params[‘token’];
$form_data = array(
‘token’ => $token,
‘action’ => ‘Login’,
‘attendanceCheck’ => ‘0’
);
// Initialize cURL session
$curl = curl_init();
// Set cURL options
curl_setopt_array($curl, array(
CURLOPT_URL => $link,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($form_data)
));
// Execute cURL request
$response = curl_exec($curl);
// Check for errors
if (curl_errno($curl)) {
echo ‘Error: ‘ . curl_error($curl);
} else {
//Done
exit();
}
// Close cURL session
curl_close($curl);
}
?>