Java apache Httpclient form-based login myspace -


so trying login website (in example myspace) using apache's httpclient v.4 not sure going wrong in process, when test code, post login cookies same initial login cookies, shouldn't be.

i have looked around online see if else has tried, haven't found resource has worked me.

i using example: apache httpclient access facebook ( facebook)

 try{         defaulthttpclient httpclient = new defaulthttpclient();          httpget httpget = new httpget("http://www.myspace.com/auth/form");          httpresponse response = httpclient.execute(httpget);         httpentity entity = response.getentity();          system.out.println("login form get: " + response.getstatusline());         if (entity != null) {             entity.consumecontent();         }         system.out.println("initial set of cookies:");         list<cookie> cookies = httpclient.getcookiestore().getcookies();         if (cookies.isempty()) {             system.out.println("none");         } else {             (int = 0; < cookies.size(); i++) {                 system.out.println("- " + cookies.get(i).tostring());             }         }          httppost httpost = new httppost("http://www.myspace.com/auth/form");          list <namevaluepair> nvps = new arraylist <namevaluepair>();         nvps.add(new basicnamevaluepair("email", "someemail"));         nvps.add(new basicnamevaluepair("password", "somepassword"));          httpost.setentity(new urlencodedformentity(nvps, http.utf_8));          response = httpclient.execute(httpost);         entity = response.getentity();         //system.out.println("double check we've got right page " + entityutils.tostring(entity));          system.out.println("login form get: " + response.getstatusline());         if (entity != null) {             entity.consumecontent();         }          system.out.println("post logon cookies:");         cookies = httpclient.getcookiestore().getcookies();         if (cookies.isempty()) {             system.out.println("none");         } else {             (int = 0; < cookies.size(); i++) {                 system.out.println("- " + cookies.get(i).tostring());             }         }         httpclient.getconnectionmanager().shutdown();     }     catch(exception e){e.printstacktrace();} 

example cookie:

    [version: 0][name: mscountry][value: us][domain: .myspace.com][path: /][expiry: tue jun 12 23:22:15 edt 2012] [version: 0][name: msculture][value: ip=xxx.xxx.xxxx&ipculture=en-us&preferredculture=en-us&preferredculturepending=&country=vvm=&forcedexpiration=0&timezone=0&mystuffdma=&mystuffmarket=&usrloc=randomuserlocstring==&userfirstvisit=1][domain: .myspace.com][path: /][expiry: tue jun 12 23:22:15 edt 2012] [version: 0][name: sessionddf2][value: randomstringhere==][domain: .myspace.com][path: /][expiry: sat jun 05 23:22:15 edt 2032] 

why think initial cookies , post cookies should different? application server side assigns set of cookies client , stays same throughout session.

the application server associates set of attributes associated session (using cookies lookup), , decides whether session 'logged-in' or not.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -