Importing Hotmail Address Book using Jakarta HttpClient

Hi,
I am using jakarta httpclient to import hotmail address book. For that i am loading the login form first and then retrieving dynamic parameters and then posting the form for authentication of user.
I am unable to authenticate user after posting the form , it redirects me to the login page.
Can somebody help me to figure out what i am missing in my code??
Following is the code i have written so far:
(To run java one will need to enter hotmail emailId and password in the loginData)
package msn.contacts.fetcher;
import java.io.InputStream;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.cyberneko.html.parsers.DOMParser;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
public class MSNContactsFetcher {
     private String msnLoginUrl = "http://login.live.com/login.srf";
     public void login(){
          HttpClient httpClient = new HttpClient();
          httpClient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
          int statusCode = -1;
          InputStream responseStream = null;
          DOMParser parser = null;
          InputSource source = null;
          try{
               GetMethod loadForm = new GetMethod(msnLoginUrl);
               loadForm.setFollowRedirects(true);
               statusCode = httpClient.executeMethod(loadForm);
               /*Header[] headers = loadForm.getResponseHeaders();
               for(int i= 0;i<headers.length;i++){
                    System.out.println("Header name:: " + headers.getName() + " value::: " + headers[i].getValue());
               System.out.println("Hotmail Status Code::: " + statusCode );          
               if(statusCode == HttpStatus.SC_OK){
                    System.out.println("Hotmail Login Form Loaded Successfully");
                    System.out.println(loadForm.getResponseBodyAsString());
                    //System.exit(1);
                    String PPFT = null;
                    String PPSX = null;
                    String loginFormAction;
                    parser = new DOMParser();
                    responseStream = loadForm.getResponseBodyAsStream();
                    source = new InputSource(responseStream);
                    parser.parse(source);
                    Node form = parser.getDocument().getElementsByTagName("form").item(0);
                    NamedNodeMap attributes = form.getAttributes();
                    String formAction = attributes.getNamedItem("action").getNodeValue();
                    System.out.println("Form action ::: " + formAction);
                    NodeList inputElements = parser.getDocument().getElementsByTagName("input");
                    Node inputNode;
                    String name;
                    for(int i=0;i<inputElements.getLength();i++){
                         inputNode = inputElements.item(i);
                         name = inputNode.getAttributes().getNamedItem("name").getNodeValue();
                         //System.out.println(name + " " + inputNode.getAttributes().getNamedItem("value").getNodeValue() );
                         if(name.equals("PPFT")){
                              PPFT = inputNode.getAttributes().getNamedItem("value").getNodeValue();
                         else if(name.equals("PPSX")){
                              PPSX = inputNode.getAttributes().getNamedItem("value").getNodeValue();
                         else if(PPFT != null && PPSX!= null)
                              break;
                         else
                              continue;
                    System.out.println("PPFT::: " + PPFT + " PPSX::: " + PPSX );
                    NameValuePair[] loginData = {
                              new NameValuePair("PPSX",PPSX),
                              new NameValuePair("PwdPad","IfYouAreReadingThisYouHaveTooMuc"),
                              new NameValuePair("login","<emailId>"),
                              new NameValuePair("passwd","<password>"),
                              new NameValuePair("LoginOptions","3"),                              
                              new NameValuePair("PPFT",PPFT)                              
                    PostMethod postLoginForm = new PostMethod(formAction);                         
                    postLoginForm.setRequestBody(loginData);
                    httpClient.executeMethod(postLoginForm);
                    statusCode = postLoginForm.getStatusCode();
                    System.out.println("Status Code::: " + statusCode);
                    String responseString = postLoginForm.getResponseBodyAsString();
                    System.out.println("Response string:: " + responseString);
          }catch(Exception ex){
               System.out.println("Exception Occurred -->> " + ex.getMessage());
               ex.printStackTrace();
     public static void main(String[] args) {
          System.getProperties().setProperty("httpclient.useragent", " Mozilla/5.0 (Win98; I;Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4");
          System.setProperty("org.apache.commons.logging.Log","org.apache.commons.logging.impl.SimpleLog");
          System.setProperty("org.apache.commons.logging.simplelog.showdatetime","true");
          System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header","debug");
          MSNContactsFetcher msn = new MSNContactsFetcher();
          msn.login();

are you having issues with the initial login, or is hotmail successfully taking your information, but failing to remember it when you access more of the site for address book information gathering?
If the first part is happening, you're probably not setting up your connection within a SSL environment correctly (I'm only guessing that's what hotmail uses, as I'm not a hotmail user). There's plenty of documentation on apache's jakarta site on how to do this/troubleshoot it.
If you're connecting, and it's not holding the information, then the cookie storing is not set up right. In that case, you may want to post a new topic more specifically relating to cookies (probably want to do it in the networking section of these forums, as it's far more pertinent there).
I wish I could help you more, but I am far more familiar with instantiating web connections via the UrlConnection class, and not with the Jakarta Commons libraries. :(

Similar Messages

  • Importing yahoo, gmail & hotmail address book  using JSP

    Hi,
    i want to import the yahoo , gmail & hotmail contacts to my local MS access database. please give me the algorithm for importing contacts & if any one having the sample codes send it to me.. if any greatly appriciated.
    Thanks in advance.
    Regards
    Chinna

    are you having issues with the initial login, or is hotmail successfully taking your information, but failing to remember it when you access more of the site for address book information gathering?
    If the first part is happening, you're probably not setting up your connection within a SSL environment correctly (I'm only guessing that's what hotmail uses, as I'm not a hotmail user). There's plenty of documentation on apache's jakarta site on how to do this/troubleshoot it.
    If you're connecting, and it's not holding the information, then the cookie storing is not set up right. In that case, you may want to post a new topic more specifically relating to cookies (probably want to do it in the networking section of these forums, as it's far more pertinent there).
    I wish I could help you more, but I am far more familiar with instantiating web connections via the UrlConnection class, and not with the Jakarta Commons libraries. :(

  • Exporting hotmail contacts to Address Book using numbers

    Hi, I've been reading some other topics on how to export your contacts to address book. Though these were helpful, I do not have microsoft excel. Is it possible to get my hotmail contacts to my address book using numbers or do I need excel.

    Hello,
    If you go into Entourage's preferences, you'll also find the option to "Synchronize" with Address book.
    The option is under the Entourage menu
    Choose Preferences
    Then, go to General, and choose Sync Services
    The option you need should be the first option in the list on the Sync Services screen.
    It should have a box to check located next to: "Synchronize Contacts with Address Book and .Mac".
    Give that a shot.
    I hope this helps.
    Let us know if you have other questions.
    P.S., if you'd like, go ahead and click the "Helpful" or "Solved" buttons on any of the posts / replies above if you feel they were helpful or adequately answered your question.

  • How can I import my address book from aol and hotmail email to my iphone

    How can I import my address books from my aol and hotmail accounts to my Iphone4?

    First you must import them to your computer, and then sync your iPhone to your computer.
    http://www.juliakm.com/transferring-aol-address-book-apple039s-address-book
    http://email.about.com/od/windowslivehotmailtips/qt/Export_Contacts_Email_Addres ses_from_Windows_Live_Hotmail.htm

  • The hotmail address i use for my apple ID was hacked and i no longer have access to it, this is stopping me from accessing any of my icloud or itunes. how can i fix this?

    The hotmail address i use for my apple ID was hacked and i no longer have access to it, this is stopping me from accessing any of my icloud or itunes. how can i fix this?

    Thanks, I appreciate the help.  I think this is one of the problems Apple is creating by changing the OS so often. I had fomer colleagues at [a major aerospace contractor] who told me that so many original files were ultimately lost because of the deadly change in the "Save As" operation that they are now afraid of every OS update. Apple has badly damaged their support base with that very prominent company (they won't update now until they've fully examined and understand changes in the pre-conditioned nature of OS computer functions), and they are a whole lot less enthaled with Mac-related equipment/software. Can't blame them, I too used orginal files that way (as easy-to-use templates), and lost some important files before I realized what was happening (to late to revert). Companies should not have to retrain employees each time an OS gets an update, it's can be very expensive several different ways. They learned a painful lesson with that one. And because I'm now retired and don't use multiple devices, I need iCloud like I need a hole in the head... but I'm told there's no way to keep Apple out of my computer. Fortunately, because of major problems when initially installing Mountain Lion, one hold-over of the hardware/software damage I experienced was that iCloud can no longer access my computer even though everything else is working fine again. That was the only "good luck" I had as a result of that expensive nightmare.

  • How do I import the address book from another hard drive?

    I wish to know if t is possible to import the address book from a slave drive that is bootable, but operating system (XP Pro Sp3) is not supported by my new motherboard. Thank you.

    '''If the address book is LDIF or .csv or Text file:'''
    In Address Book:
    * Tools > Import
    * Select 'Address Books' and click on Next
    * select: 'Text file(LDIF, .tab, .csv, .txt) and click on Next.
    * You might need to map the column headers.
    '''If the address book is a .mab file or .csv file :'''
    you could use this addon tool: MoreFunctionsForAddressBook
    * https://nic-nac-project.org/~kaosmos/morecols-en.html
    '''How to install addon:'''
    Download the .xpi file to your eg: Desktop
    In Thunderbird
    * 'Tools' > 'Addons' OR 'Menu Icon' > 'Addons'
    * clickon gear wheel icon and select 'Install addon from file'
    * locate the file you downloaded and click on 'Open'
    * You may need to restart Thunderbird.
    In Address Book
    'Tools' > 'MorefunctionsForAddressBook' > 'Actions for address books' > choose option required and then select the .mab file or .csv file

  • Java Code to scrape a hotmail address book

    Hi all... Can anyone help with trying to scrape a hotmail address book based on the user-id and password given with the help of a java program.. I tried using HTML Unit to do this but the process seems too tedious.. and cant really figure out the hidden variables n stuff in the hotmail website.
    Please help me out.... !! thanx !!

    Yes i did try that though... But it didnt work... I've made use of HTMLUnit to do this .. I've extracted all the hidden variables and tried to re-post them.. But still wasnt able to sign in to Hotmail through Java.. Here's the code that i tried...
    String PwdPad="IfYouAreReadingThisYouHaveTooMuchFreeTime";
              final WebClient webClient=new WebClient(BrowserVersion.INTERNET_EXPLORER_6_0);
              webClient.setRedirectEnabled(true);          
              //Get the hotmail page
              final URL url=new URL("http://www.hotmail.com");
              HtmlPage homePage=null;
              homePage=(HtmlPage)webClient.getPage(url);
              Search(homePage);
              final HtmlForm form=homePage.getFormByName("f1");
              final HtmlSubmitInput button=(HtmlSubmitInput) form.getInputByName("SI");
              //Settting the user name and password
              final HtmlTextInput text1=(HtmlTextInput) form.getInputByName("login");
              final HtmlPasswordInput text2=(HtmlPasswordInput) form.getInputByName("passwd");
              //Hidden Variables
              final HtmlHiddenInput ppsx=(HtmlHiddenInput) form.getInputByName("PPSX");
              final HtmlHiddenInput pwdpad=(HtmlHiddenInput) form.getInputByName("PwdPad");
              final HtmlHiddenInput ppft=(HtmlHiddenInput) form.getInputByName("PPFT");
              System.out.println("The Action is:: "+form.getActionAttribute());
              //Re-posting the Entries (PPSX,Login,Password,PwdPad,PPFT)
              int len;
              len=PwdPad.length()-pass.length();
              PwdPad = PwdPad.substring(0, len);
              text1.setValueAttribute(email);
              text2.setValueAttribute(pass);
              //ppsx.setValueAttribute( ppsx.getValueAttribute());
              //pwdpad.setValueAttribute( PwdPad);
              //ppft.setValueAttribute( ppft.getValueAttribute());
              System.out.println("user:"+text1.getValueAttribute() + " password:" + pass+" ppsx:"+ppsx.getValueAttribute()+" PwdPad:"+pwdpad.getValueAttribute()+" ppft:"+ppft.getValueAttribute() + " login opts:");
              //URL postURL = new URL ("https://login.live.com/ppsecure/post.srf?id=2&bk=1185180903") ;
              URL postURL = new URL (form.getActionAttribute()) ;
              WebRequestSettings webRequestSettings = new WebRequestSettings(postURL,SubmitMethod.POST);
              String requestBody = "PPSX="+ ppsx.getValueAttribute() +"&PwdPad="+PwdPad+"&login=email%40hotmail.com&passwd="+pass+
                        "&LoginOptions=2&PPFT=" + ppft.getValueAttribute() ;
              webRequestSettings.setRequestBody(requestBody);
              //HtmlPage page= ( HtmlPage ) webClient.getPage(webRequestSettings);
              HtmlPage page=(HtmlPage)button.click();
              System.out.println(page.asText());

  • When importing my address book from Outlook why do I have multiple entries for the same contact?

    I have an address book and it contains one list in Outlook. I just downloaded Thunderbird and imported my address book. The address book and one list imported very easily but there are anywhere from 3-5 entries for each person in my contacts. If I delete the extras they are removed from my list as well. Why are there multiple listings for each contact and how can I remove the duplicates without losing my list entries?

    as I was looking thru pictures in my finder I noticed there were several copies of the same pictures I had taken yesterday. I just went thru all Seven copies of the pictures (accidental pics of my hands and the desk etc) and right clicked and moved  them to trash, then I thought I'd look it up when I realized its not just these pics, but very many had een stored in groups of three or four.
    1. Why is that?
    Depends on where you saw them - If they were in the iPhoto library iPHoto has either two or three different versions (no duplicates) or each photos in its library - this is not optional and can not be changed  --  If they were not in the iPhoto library then you can do what you please with them and they have nothing to do with iPhoto - iPhoto is only involved with the photos in its library
    2. Why is it advised to NEVER make changes to the structure or contents of iPhoto in Finder?
    (as quoted Below)
    "I would suggest using one of the proven safe programs - if you are going to manually remove them be sure to remember that you NEVER make any chnages to the structure or contents of the iPhoto library using the finder - only make changes using iPhoto"
    Very simple - if you do you will destroy your iPhoto library and have to start over losing all work you have done in iPhoto - The iPHoto library is a SQLite database and there are NO user servicable parts in the iPhoto library and any changes made using teh finder will corrupt the database and cause dataloss
    Is that a good enopugh reason for you?
    So if these photos were in the iPhoto library when you
    I just went thru all Seven copies of the pictures (accidental pics of my hands and the desk etc) and right clicked and moved  them to trash,
    You destroyed your iPhoto library and will either have to restore your backup from before you did this. put everything back EXACTLY like it was before or start over
    LN

  • Can I import my address book into Adobe Send?

    How do I import my address book into Adobe Send?

    Hi propacific,
    There is no way to port your address book into Adobe Send, but if you use Send through Adobe Reader, you can access your local address book. And, if you're on Windows, you can use the Outlook plug-in for Adobe Send so you can send directly from Outlook. You can download the plug-in from here: Send Large Files Online - Share, Control, Track & Manage | Adobe Send
    Best,
    Sara

  • I have been forced to join Qwest email.  Is there a way I can get back to mail?  If not, how can I import my address book to Qwest?

    I have been "forced" to join Qwest email.  Is there a way I can get back to used Mail?  If not, how can I import my Address Book to Qwest email?
    carolfromwhitebearlake

    It sounds like you use Quest as your ISP, or whoever you have as your ISP is being taken over by Quest. If this is the case it is possible that your email server is being transitioned to Quest and you will need to change your email address and server settings.
    I am only speculating since I do not have enough information. I suggest calling your ISP or Quest and ask their help desk about this.

  • How do i import my address book from PC to Apple ?

    How do i import my address book from PC to Apple?
    Thanks
    Steve

    With many applications it's just a matter of dragging the file that has all the addresses into the address book. If for some reason that doesn't work you can use the import function of the address book. If you happen to have them in Outlook here is one way:
    http://www.myfirstmac.com/index.php/mac/articles/outlook-to-address-book/
    Roger

  • I must import my address book from my old Yahoo account? How do I do that?

    I need to import my address book from my old Yahoo account to AOL and
    Windows Live. I cannot find a way to do this.
    == This happened ==
    A few times a week
    == I left Yahoo and went to AOL & Windows live.

    Sorry, Firefox doesn't do email, it's strictly a web browser, and thus has no use for an Address Book.
    If you are using Firefox to access your mail, you are using "web-mail". You need to seek support from your service provider or a forum for that service.
    If your problem is with Mozilla Thunderbird, see this forum for support.
    [http://www.mozillamessaging.com/en-US/support/]
    or this one
    [http://forums.mozillazine.org/viewforum.php?f=39]

  • Importing Tiger Address Book Archives

    FYI. When Importing Address Book archives from Tiger the address book application does not always show the newly imported addresses.
    So do the following:
    - Imported the address book
    - Replace all contents
    - Quit Address Book app
    - Relaunch Address Book and check addresses are there.
    I use the Archive facility to switch between Personal and Business addresses books.

    I see this happen sometimes too - restarting is sometimes necessary to refresh the contact list.

  • Can i download my Hotmail address book onto my phone?

    Or do i have to enter this manually for each contact?
    I'd really appreciate it if you could help.
    Thanks,

    I don't do Hotmail, but if you can determin how to download or export your hotmail address book to your PC (like an ASCII, CSV or Excel file), then you can import that data into Outlook to sync to your BlackBerry.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Import Pine Address Book

    I'm using iMS5.2
    Can I import pine address book from old aix server into Messaging Server address book ?

    Not a supported option.
    If you're handy with programming, you could likely manage it. Check the Schema Guide for how the PAB works, and see if you can massage the Pine data into something you can use ldapmodify to create.

Maybe you are looking for

  • Crystal Report orange link arrow to SAP B1 not working

    Hello, I couldn't find a way to insert the actual "arrow" icon into a Crystal report so I copied one from one of the Crystal Reports imbedded in SAP B1 9.0.  I subsequently edited the hyperlink to point to the document number I wanted. From the Forma

  • 2D array output in a loop

    Hello, I need output data (several array string) from FOR-loop to 2D array. I use Replace array subset inside the loop (after array initialize). Output works (I see each step right string in its right place), But each next loop clear all previous str

  • Pan & Zoom - Different renditions

    I have a 4 pan and zoom objects that are just fine in a 1024 x 768 for horizontal and vertical rendition of my article. I created an alternate layout for the iPad 3/4 - 2048 x 1536 for horizontal and vertical. I cannot upload my article to my folio b

  • Standard Report check whether Goods Issue has been performed for DN

    Hi All, My users is having a list of DNs where they would like to check if Post Goods Issue has been performed for them.  I would like to ask is there any standard reports as to check if a Delivery Note has PGI performed? I have tried report VL06G bu

  • RE: (forte-users) Events in Interface

    I know, I've implemented similar structures in other locations as well, always without problems. I've even recreated the whole interface, building it completely from dragging and dropping methods and events from the class to the interface. Then I did