Welcome Guest, Not a member yet? Register   Sign In
Fetch contacts from Hotmail
#1

[eluser]Sawariya[/eluser]
Hai Friends
How to retrieve cotacts from hotmail?
help me plzzzzzzzzzzzzzz
Thanks
#2

[eluser]wiredesignz[/eluser]
Sheesh, At least try to work something out for yourself, then ask Tongue
#3

[eluser]frenzal[/eluser]
it's like a lolcat typed that message, "i can has cheezburger?"

anyway, to not go completely offtopic, maybe have a look at how some of these did it:
http://www.hotscripts.com/PHP/Scripts_an...index.html
#4

[eluser]Pascal Kriete[/eluser]
You will get a lot more answers if you have done your homework. That means having at least some idea at how you want to go about doing this (google helps), and preferably some sample code.
Also asking the question clearly and in the best English you can manage not only looks more professional, it also feels like a much more genuine request. I realise there are a lot of foreigners on this board (myself included), but while grammar mistakes and the occasional typo are totally acceptable, blatant misspellings are not. This board has a spell checker that works quite well.

As for the original request, all sources I have found so far suggest that you will probably need to build a screen scraper. I couldn't find a public API.
#5

[eluser]MrBaseball34[/eluser]
Having done some work with Hotmail before, although it was using Delphi and not PHP, I can say that it shouldn't be that difficult as Hotmail can be queried using XMLHTTPRequest because it uses WebDAV.

I have some Delphi code to retrieve the Contacts but can't translate to PHP even though I know PHP quite well. If someone wants to help out on the translation, I'll be glad to demonstrate how to gather the contacts from Hotmail.
#6

[eluser]wiredesignz[/eluser]
I use Delphi also, can you either PM me your Delphi code or post it in the Lounge forum. I'll try to port it to PHP. Tongue
#7

[eluser]matt2012[/eluser]
Ive used the api at http://www.rapleaf.com/apidoc/v2/abook

You will need to get yourself an api key.

First page ask for email and password then post it to second page - call it contacts_list

then in the corresponding controller

Code:
function contacts_list()
    {
        if( isset($_POST['unm']) && isset($_POST['pwd']) )
        {
        $ch = curl_init();
        $unm = $_POST['unm'];
        $pwd = $_POST['pwd'];
        $url = "https://api.rapleaf.com/v2/abook/?api_key=YOUR_API_KEY_GOES_HERE&login;=".$unm."&password;=".$pwd;
        curl_setopt( $ch, CURLOPT_URL, $url);
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
        curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
        $result = curl_exec( $ch ); # run!
        curl_close($ch);
        if($result=='Login Failed: email address or password were incorrect' || $result=='Invalid login email address')
        {
        echo $result;
        }
        else
        {
        echo '<ul id="contacts">';
                $xml = new SimpleXMLElement($result);
                foreach ($xml->contact as $name)
                {
                echo '<li class="c1">' .  $name['name'] . ' ' . $name['email'] .  '</li>';
                }
        echo '<ul>';
        }
        }

Note this is a bit of a hack really you should use XML-RPC class but my initial attempt failed and this worked if someone does get this working with XML-RPC I would love to see it (maybe post it here).
#8

[eluser]MrBaseball34[/eluser]
[quote author="wiredesignz" date="1203568755"]I use Delphi also, can you either PM me your Delphi code or post it in the Lounge forum. I'll try to port it to PHP. Tongue[/quote]

While testing the code today, I have found that it no longer works because something has changed. It seems that, even though you set the UserAgent in your initial XMLHTTPRequest, the redirect by services.msn.com modifies it and you get an 801: Invalid UserAgent error.

In capturing the Address book Synch HTTP traffic using OE and Windows Address Book, I find that the same UA is being sent al the way through the transaction.

I can provide it but am not sure if even converting it to PHP will work.

I will post it in this thread tomorrow.

BTW, I have found a couple of PHP WebDAV classes and am looking at one right now to help with the conversion. Any class MUST support PROPFIND to get the AB data.
#9

[eluser]MrBaseball34[/eluser]
Code:
oXMLHTTP and oXMLDoc are defined as:
    oXMLDoc:                   IXMLDOMDocument2;
    oXMLHTTP:                  IXMLHTTPRequest;

and created in the formcreate like this:
  oXMLDoc  := CreateOleObject('MSXML2.DOMDocument.3.0') as IXMLDOMDocument2;
  oXMLHTTP := CreateOleObject('MSXML2.XMLHTTP') as IXMLHTTPRequest;
  
GET_AB_DATA and AB_UA consts are defined as:
const
  GET_AB_DATA         = '&lt;?xml version="1.0"?&gt;'+
                        '&lt;D:propfind xmlns:D="DAV:" '+
                        '            xmlns:h="http://schemas.microsoft.com/hotmail/" '+
                        '            xmlns:c="urn:schemas:contacts:"&gt;'+
                        '  <D:prop>'+
                        '    <D:id/>'+
                        '    <c:group/>'+
                        '    <h:modified/>'+
                        '    <c:cn/>'+
                        '    <c:givenName/>'+
                        '    <c:sn/>'+
                        '    <c:nickname/>'+
                        '    <c:mail/>'+
                        '    <c:homeStreet/>'+
                        '    <c:homeCity/>'+
                        '    <c:homeState/>'+
                        '    <c:homePostalCode/>'+
                        '    <c:homeCountry/>'+
                        '    <c:o/>'+
                        '    <c:street/>'+
                        '    <c:l/>'+
                        '    <c:st/>'+
                        '    <c:postalcode/>'+
                        '    <c:co/>'+
                        '    <c:homePhone/>'+
                        '    <c:homeFax/>'+
                        '    <c:telephoneNumber/>'+
                        '    <c:facsimiletelephonenumber/>'+
                        '    <c:mobile/>'+
                        '    <c:otherTelephone/>'+
                        '    <c:bday/>'+
                        '    <c:pager/>'+
                        '  </D:prop>'+
                        '</D:propfind>';

AB_UA = 'Windows-Address-Book/6.0 '+
         '(MSIE 6.0; Windows NT 5.1; '+
         'Installed by Symantec Package; SV1; '+
         'Embedded Web Browser from: http://bsalsa.com/; '+
         '.NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.1; '+
         '.NET CLR 3.0.04506.648; .NET CLR 3.5.21022)';
  

procedure TfmHotmailForm.GetABData;
var
  oElement        : IXMLDOMElement;
  oNodeList       : IXMLDOMNodeList;
  sl: TStringList;
begin
  if (Length(FUsername) = 0) then
    oXMLHTTP.open('PROPFIND', FContactsURL, False, '', '')
  else
    oXMLHTTP.open('PROPFIND', FContactsURL, False, FUsername, FPassword);

    oXMLHTTP.setRequestHeader('PROPFIND',
                              GET_AB_DATA);
    oXMLHTTP.setRequestHeader('Content-Type',
                              'text/xml');
    oXMLHTTP.setRequestHeader('Depth', '0');
    oXMLHTTP.setRequestHeader('User-Agent',
                              AB_UA);
  oXMLHTTP.send(EmptyParam);
  (*
    There seems to be a problem getting this data now as, on the redirect, the HTTPMail
    control is switching UserAgents and we get a X-Dav-Error: 801 Invalid User-Agent
  *)
  FResponseHdrs := oXMLHTTP.getAllResponseHeaders;
  FResponseText := oXMLHTTP.ResponseText;
  oXMLDoc.LoadXML(FResponseText);
  Result := oXMLDoc.childNodes.length > 0;
  if Result then
  begin
    oElement       := oXMLDoc.documentElement;
    oNodeList      := oElement.childNodes;
    if oNodeList.length > 0 then
    begin
      // iterate through the nodes to get the data. See daata example below
    end;
  end;
end;
#10

[eluser]MrBaseball34[/eluser]
Code:
Example of abdata returned from Hotmail:

&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;D:multistatus xmlns:c="urn:schemas:contacts:" xmlns:h="http://schemas.microsoft.com/hotmail/" xmlns:D="DAV:"&gt;
    <D:response>
      <D:href>http://contacts.msn.com/cgi-bin/hmdata/[email protected]/abdata/1dbd0527-13ea-4cca-8c4e-1cf32a34f7a8.0</D:href>
      <D:propstat>
        <D:prop>
          <D:id>1dbd0527-13ea-4cca-8c4e-1cf32a34f7a8.0</D:id>
          <h:modified>2008-02-21T10:07:17</h:modified>
          <c:nickname>president</c:nickname>
          <c:mail>[email protected]</c:mail>
          <c:givenName>George W. Bush</c:givenName>
          <c:sn>Bush</c:sn>
          <c:homeStreet>1600 Pennsylvania Ave. NW</c:homeStreet>
          <c:homeCity>Washington</c:homeCity>
          <c:homeState>DC</c:homeState>
          <c:homePostalCode>20500</c:homePostalCode>
          <c:homeCountry>USA</c:homeCountry>
          <c:o>White House</c:o>
          <c:street>1600 Pennsylvania Ave. NW</c:street>
          <c:l>Washington</c:l>
          <c:st>DC</c:st>
          <c:postalcode>20500</c:postalcode>
          <c:co>USA</c:co>
          <c:homePhone>202-456-1414</c:homePhone>
          <c:telephoneNumber>202-456-1111</c:telephoneNumber>
          <c:pager>none</c:pager>
          <c:homeFax>202-456-2461</c:homeFax>
          <c:mobile>none</c:mobile>
          <c:otherTelephone>none</c:otherTelephone>
          <c:bday>1946-07-06</c:bday>
        </D:prop>
        <D:status>HTTP/1.1 200 OK: Properties Found</D:status>
      </D:propstat>
    </D:response>
    <D:response>
      <D:href>http://contacts.msn.com/cgi-bin/hmdata/[email protected]/abdata/b7f66989-4f4a-440e-ab97-251a44c07d07.1</D:href>
      <D:propstat>
        <D:prop>
          <D:id>b7f66989-4f4a-440e-ab97-251a44c07d07.1</D:id>
          <h:modified>2007-10-24T06:34:42</h:modified>
          <c:group />
          <c:nickname>Coworkers</c:nickname>
        </D:prop>
        <D:status>HTTP/1.1 200 OK: Properties Found</D:status>
      </D:propstat>
    </D:response>
    <D:response>
      <D:href>http://contacts.msn.com/cgi-bin/hmdata/[email protected]/abdata/c7441b9c-35a9-4f18-aefb-7b2a7ad2bef2.1</D:href>
      <D:propstat>
        <D:prop>
          <D:id>c7441b9c-35a9-4f18-aefb-7b2a7ad2bef2.1</D:id>
          <h:modified>2008-02-21T10:07:17</h:modified>
          <c:group />
          <c:nickname>Family</c:nickname>
        </D:prop>
        <D:status>HTTP/1.1 200 OK: Properties Found</D:status>
      </D:propstat>
    </D:response>
    <D:response>
      <D:href>http://contacts.msn.com/cgi-bin/hmdata/[email protected]/abdata/ebcf516d-7e5a-4c0f-b73f-99ffd7a38f4d.1</D:href>
      <D:propstat>
        <D:prop>
          <D:id>ebcf516d-7e5a-4c0f-b73f-99ffd7a38f4d.1</D:id>
          <h:modified>2007-10-24T06:34:42</h:modified>
          <c:group />
          <c:nickname>Friends</c:nickname>
          <c:mail>[email protected]/c:mail>
        </D:prop>
        <D:status>HTTP/1.1 200 OK: Properties Found</D:status>
      </D:propstat>
    </D:response>
  </D:multistatus>


Data returned in FResponseHdrs (includes error):
Date: Thu, 21 Feb 2008 16:22:21 GMT
Server: Microsoft-IIS/6.0
P3P:CP="BUS CUR CONo FIN IVDo ONL OUR PHY SAMo TELo"
X-Powered-By: ASP.NET
X-MSNSERVER: BAYABCHWBB134
X-AspNet-Version: 2.0.50727
X-Dav-Error: 801 Invalid User-Agent
Cache-Control: private
Content-Length: 0




Theme © iAndrew 2016 - Forum software by © MyBB