I've never done something like this before...I'm trying to log into swagbucks.com and get retrieve some information, but it's not working. Can someone tell me what's wrong with my script?

$pages = array('home' =>
           'login' =>
           'schedule' =>
$ch = curl_init();
//Set options for curl session
$options = array(CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; `rv:1.9.2) Gecko/20100115 Firefox/3.6',`
         CURLOPT_COOKIEFILE => 'cookie.txt',
         CURLOPT_COOKIEJAR => 'cookies.txt');

//Hit home page for session cookie
$options[CURLOPT_URL] = $pages['home'];
curl_setopt_array($ch, $options);

$options[CURLOPT_URL] = $pages['login'];
$options[CURLOPT_POST] = TRUE;
$options[CURLOPT_POSTFIELDS] = 'emailAddress=lala@yahoo.com&pswd=jblake&persist=on';
curl_setopt_array($ch, $options);

//Hit schedule page
$options[CURLOPT_URL] = $pages['schedule'];
curl_setopt_array($ch, $options);
$schedule = curl_exec($ch);

//Output schedule
echo $schedule;

//Close curl session

But it still doesn't log me in. What's wrong?


You might want to censor your personal information.

Written by Bauer

+1 for not giving us real credentials

Written by Axarydax

Maybe they are checking the http referer header if you are coming from their login form? So, try to add that header as well.

Written by Martin Wickman

Accepted Answer

try to echo each request to see if something went wrong. (enabling CURLOPT_RETURNTRANSFER)

Written by Dario
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki