curl-library
RE: Unsuccessful Login
Date: Tue, 16 Nov 2010 13:43:36 -0800
Finally I made it.
It took two days but that's not terribly bad for someone who knows zero
about Internet SW and protocols.
I feel I owe a summary. Comments in the code are explanatory.
Essentially, I now can access to the site with an automated libcurl login.
Thanks everyone for all hints, directions and for the time spent replying.
=======================================================
// Login Page
const string LoginPage = "https://us.etrade.com/e/t/user/login";
// Where the POST string must go
const string Login_fcc = "https://us.etrade.com/login.fcc";
const string stPostLogin =
"USER=myUSRid&PASSWORD=myPASSwd&TARGET=%2Fe%2Ft%2Fpfm%2Fportfolioview&Logon.x=0&Logon.y=0";
// Not necessary, but it does not hurt:
curl_easy_setopt(sessionA, CURLOPT_USERAGENT, UserAgent.c_str());
// Essential! In the Header there is a Location: to follow:
curl_easy_setopt(sessionA, CURLOPT_FOLLOWLOCATION, 1);
// Regular stuff:
curl_easy_setopt(sessionA, CURLOPT_COOKIEJAR, CookiesBag);
curl_easy_setopt(sessionA, CURLOPT_COOKIEFILE, CookiesBag);
curl_easy_setopt(sessionA, CURLOPT_WRITEHEADER, HeaderFile);
// These are NOT necessary at all!
// All works 100% fine without them. Any reason why I should keep
this?
curl_easy_setopt(sessionA, CURLOPT_AUTOREFERER, 1);
curl_easy_setopt(sessionA, CURLOPT_REFERER, LoginPage.c_str());
// This is only for "visiting" the Login page and collecting the
// necessary cookies prior to POST
curl_easy_setopt(sessionA, CURLOPT_URL, LoginPage.c_str());
result = curl_easy_perform(sessionA);
// POST must go to a different page: login.fcc
curl_easy_setopt(sessionA, CURLOPT_POSTFIELDS, stPostLogin.c_str());
result = curl_easy_perform(sessionA); // then posting
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-11-16