I am trying to log into a secure site using CURL. I have successfully manually logged in using the url. When using CURL The response from the server is
You don't have permission to access example.com/login.
I suspect that the server has code in place to prevent CURL type logins for security reasons. Before I throw in the towel, are there any other parameters you would try to simulate a normal browser login? Here's my code:
define("COOKIE_FILE", "cookie.txt");
$url = "https://example.com/login/";
$username = 'username';
$password = 'password';
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "UserName=$username&Password=$password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$buf = curl_exec ($ch);
curl_close ($ch);
unset($ch);
echo $buf;