I'm trying to login to megaupload.com using cURL and PHP. What I want to do is login so I have premium access, and then download a file. This the code for my login method:
public function login()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.megaupload.com/?c=login");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username={$this->username}&password={$this->password}&login=1");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$store = curl_exec($ch);
curl_close ($ch);
}
And this is my index.php:
<?php
include_once("plugins/megaupload.class.php");
$megaupload = new Megaupload("username", "password");
$megaupload->login();
?>
But nothing seems to happen. When I run the script, cookie.txt isn't saved anywhere. I got the POST values from Firebug:
login=1&password=password&redir=1&username=username
This is what's being sent through the form when I log in using their site. And yeah, the username and password is correct.
Thanks for any help!
EDIT: Okay, it seems it is actually logging in as I can access my account page, which I wouldn't be able to unless I'm logged in. But that still doesn't solve where the cookie.txt file is being saved...