Hi,
I'm writing a script to do some search on rentacoder.com and to get certain data, I need to login. I'm using PHP cURL library. While cURL works perfectly on other pages of this site (for example, to search or to fetch a coder / project page), I cannot make it work for login. It always returns me an error page saying - "UserId or Password was blank which is not allowed". Here's my script -
function rac_login($email, $password) {
$referer = "https://www.rentacoder.com/Ads/authentication/login.asp?lngWId=&blnOutsideOfVBSubWeb=False&txtReturnURL=http%3A%2F%2Fwww%2Erentacoder%2Ecom%2FRentACoder%2Fauthentication%2FLogin%2Easp%3FtxtReturnURL%3Dhttps%253a%252f%252fwww%2Erentacoder%2Ecom%252fRentACoder%252fDotNet%252fdefault%2Easpx&txtCancelURL=%2FRentACoder%2FDotNet%2FDefault%2Easpx";
$user_agent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; bn-IN; rv:1.9.0.16) Gecko/2009120208 Firefox/3.0.16 (.NET CLR 3.5.30729)";
$url = "https://www.rentacoder.com/ads/authentication/LoginAction.asp";
$return_url = "http://www.rentacoder.com/RentACoder/authentication/Login.asp?txtReturnURL=https%3a%2f%2fwww.rentacoder.com%2fRentACoder%2fDotNet%2fdefault.aspx";
$data = array('txtReturnURL' => urlencode($return_url), 'lngWId' => '1', 'blnOutsideOfVBSubWeb' => 'False', 'strPassKey' => '','txtEmailAddress' => urlencode($email),'txtPassword' => urlencode($password), 'cmOk' => 'Ok');
$cookie_file_path = "rac_login_cookie.txt";
$fp = fopen("stderr.txt","a");
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect:"));
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch ,CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_STDERR, $fp);
$resp = curl_exec($ch);
curl_close($ch);
fwrite($fp,$r);
fclose($fp);
}
rac_login("your_email","your_password");
I've used both firebug and live http headers to check the post variables. They're all the same in both.
Does it have something to do with https that it's not working?
Also note that, rentacoder make 3/4 redirects while logging in. So you might want to disable javascript if you want to test using firebug.
Thanks in advance.