Ok, so I'm trying to use CURL to login to my cpanel (and eventually add on subdomains from a list for me automatically), but it refuses to login for me. Here's what I've got so far...
However all it does is echo the cpanel login screen instead of the screen you get once you're logged in...any idea where I'm going wrong here?
PHP:
<?php
// INIT CURL
$ch = curl_init();
// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'www.example.com:2082');
// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'login_theme=cpanel&user=USERNAME&pass=PASSWORD');
// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'http://www.example.com/curl/cookie.txt');
# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);
echo curl_exec($ch);
// CLOSE CURL
curl_close ($ch);
?>
However all it does is echo the cpanel login screen instead of the screen you get once you're logged in...any idea where I'm going wrong here?