I want to login to a remote website from mine. So, I used cURL to achieve this and I was successful using the code below:
function login($url,$data)
{
$fp = fopen("cookie.txt", "w");
fclose($fp);
$login = curl_init();
curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($login, CURLOPT_TIMEOUT, 40000);
curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($login, CURLOPT_URL, $url);
curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($login, CURLOPT_POST, TRUE);
curl_setopt($login, CURLOPT_POSTFIELDS, $data);
ob_start();
return curl_exec ($login);
ob_end_clean();
curl_close ($login);
unset($login);
}
So for posting data I used the raw data for the form in the website. Which I managed to get from developer tools in Edge.Here is the screenshot of raw POST data when I try to login directly in the remote website (http://vce.ac.in)
The problem is the values of the parameters viewstate, validation, viewstategenerator are changing for every 24 hours.
So if there is a method in PHP to get the raw POST data of the website, I can update those values of raw data parameters which are changing.