Automatic Login to Mint.com

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jasonlfunk
Forum Newbie
Posts: 5
Joined: Sun Oct 18, 2009 7:22 pm

Automatic Login to Mint.com

Post by jasonlfunk »

Hello Everyone,

In an expression of experimentation and irony, I'm am trying to write a script that logs into mint.com and downloads my transaction list. I cannot seem to figure out how it works. I've tried a curl script and well as a stream but neither have worked. My curl script looked like this:

Code: Select all

 
<?php
// INIT CURL
$ch = curl_init();
 
// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'https://wwws.mint.com/loginUserSubmit.xevent');
 
// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);
 
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'username=[USERNAME]&password=[PASSWORD]&task=L');
 
// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, '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)
$saved = curl_exec ($ch);
if(!$saved)
{
        echo "Error: " . curl_error($ch);
}
// SET FILE TO DOWNLOAD
curl_setopt($ch, CURLOPT_URL, 'https://wwws.mint.com/transactionDownload.event?');
 
// EXECUTE 2nd REQUEST (FILE DOWNLOAD)
$content = curl_exec ($ch);
 
// CLOSE CURL
curl_close ($ch);
 
echo $content;
?>
 
(I've removed my username and password for obvious reasons but I know they are right.)


Does anyone see any problems with it or can give me any pointers to getting it to work?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Automatic Login to Mint.com

Post by requinix »

jasonlfunk wrote:but neither have worked
And how has it not worked?
jasonlfunk
Forum Newbie
Posts: 5
Joined: Sun Oct 18, 2009 7:22 pm

Re: Automatic Login to Mint.com

Post by jasonlfunk »

Sorry. I figured it out. I need to tell curl to follow redirects by adding:

curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
Post Reply