Windows Live Contacts API

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Sander hueting

sander hueting

28/04/2008 23:16:00
Quote Anchor link
Iemand die hier iets mee kan?
Windows Live Contacts API
http://msdn2.microsoft.com/en-us/library/bb463989.aspx

Wil msn contacten importeren werkt alle scriptjes op internet werken niet meer met @hotmail.com adressen, of kent iemand iets?

Groet Sander
 
PHP hulp

PHP hulp

19/03/2024 03:36:46
 

28/04/2008 23:32:00
Quote Anchor link
Misschien wat aan dit topic?
 
Sander hueting

sander hueting

29/04/2008 09:48:00
Quote Anchor link
Als jullie dit proberen http://www.indigio.nl/drop/

Hiermee log je in op MSN Live ...

Krijg je op een gegeven moment allemaal id's met link "Get contacts"

Vervolgens kun je kiezen wat je wilt weergeven waar de volgende error zich voordoet

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/indigio/domains/indigio.nl/public_html/drop/contacts.php:136 Stack trace: #0 /home/indigio/domains/indigio.nl/public_html/drop/contacts.php(136): SimpleXMLElement->__construct('') #1 {main} thrown in /home/indigio/domains/indigio.nl/public_html/drop/contacts.php on line 136

Dit is contact.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
// This is a PHP-version of the Powershell-script provided by Angus Logan
// (c) Alex van Herwijnen - www.alex-media.nl


ini_set("display_errors", "on");
error_reporting(E_ALL);

// initialize variables
$radioContacts = $radioInvite = $checkboxShowNodeList = $checkboxShowXml = null;

// what mode are we using, which radio should be checked?
if(isset($_POST["mode"]))
{

    if($_POST["mode"] == "contacts")
    {

        $radioContacts = "checked";
        $radioInvite = "";
    }

    if($_POST["mode"] == "invite")
    {

        $radioContacts = "";
        $radioInvite = "checked";
    }
}

else
{
    $radioContacts = "checked";
    $radioInvite = "";
}


// should XML be shown?
if(isset($_POST["showxml"]))
{

    $checkboxShowXml = "checked";
}


// should the node list be shown?
if(isset($_POST["shownodelist"]))
{

    $checkboxShowNodeList = "checked";
}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Windows Live Contacts</title>
</head>
<style type="text/css">
td { vertical-align: top; }
span.underline { text-decoration: underline; }
input[type=text] { width: 550px; }
p.nopadding { margin: 0; padding: 0; }
a.togglelink { font-family: monospace; }
</style>
<body>

<form action="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $_SERVER["PHP_SELF"]; ?>
" method="POST">
<table cellpadding="4" cellspacing="0" border="0">
<tr>
<td>Delegation token:</td>
<td><input type="text" name="dt" value="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $_REQUEST["dt"]; ?>
" /></td>
</tr>
<tr>
<td>CID in HEX:</td>
<td><input type="text" name="cid" value="
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $_REQUEST["cid"]; ?>
" /></td>
</tr>
<tr>
<td>Verbosity:</td>
<td><input type="checkbox" name="shownodelist" id="shownodelist"
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $checkboxShowNodeList; ?>
/><label for="shownodelist">Show Node List</label><br />
<input type="checkbox" name="showxml" id="showxml"
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $checkboxShowXml; ?>
/><label for="showxml">Show XML</label></td>
</tr>

<tr>
<td>Mode:</td>
<td><input type="radio" name="mode" value="contacts" id="contacts"
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $radioContacts; ?>
/><label for="contacts">Contacts</label><br />
<input type="radio" name="mode" value="invite" id="invite"
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<?php echo $radioInvite; ?>
/><label for="invite">Invite</label></td>
</tr>

<tr>
<td colspan="2" align="center"><button type="submit" accesskey="s" name="btnSubmit"><span class="underline">S</span>ubmit</button></td>
</tr>
</table>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php

// Here is where the magic happens. If the form has been submitted, start parsing.
if(isset($_POST["btnSubmit"]))
{

    // Make the mode lowercase so it's easier for string comparison
    $mode = strtolower($_POST["mode"]);
    echo "<hr />";

    // turn the HEX CID into a int64 LID
    $lid = unfucked_base_convert($_POST["cid"], 16, 10);

    // The mode determines the URL to use
    switch($mode)
    {
        case
"contacts":
            $rootURI = "https://livecontacts.services.live.com/users/@C@" . $lid . "/rest/livecontacts";
            break;
        case
"invite":
            $rootURI = "https://livecontacts.services.live.com/users/@C@" . $lid . "/rest/invitationsbyemail";
            break;
        default:

            die("Invalid mode");
            break;
    }


    // Print basic info
    echo "<p class=\"nopadding\"><a href=\"#\" onclick=\"return toggleVP();\" id=\"toggleVP\" class=\"togglelink\">&gt; Show values passed</a></p>";
    echo "<div id=\"valuespassed\" style=\"display: none;\"><dl>";

    echo "<dt>CID in HEX:</dt>";
    echo "<dd>".$_POST["cid"]."</dd>";

    echo "<dt>LID:</dt>";
    echo "<dd>".$lid."</dd>";

    echo "<dt>URI:</dt>";
    echo "<dd>".$rootURI."</dd>";

    echo "<dt>DT:</dt>";
    echo "<dd>".$_POST["dt"]."</dd>";

    echo "</dl></div>";

    // Get the data
    $xml = getData($_POST["dt"], $rootURI, $lid);

    // If the return data isn't false, we've received data. Let's parse it
    if($xml !== false)
    {

        $oSimpleXML = new SimpleXMLElement($xml);
        
        if(strtolower($_POST['mode']) == "contacts")
        {

            // If the mode is set to contacts, then display their names.
            $query = "//DisplayName";
        }

        else
        {
            // Else, print the e-mail addresses
            $query = "//PreferredEmail";
        }

        
        // Let's filter
        $entries = $oSimpleXML->xpath($query);

        $numEntries = count($entries);
        echo "<p>" . $numEntries . " contacts found</p>";

        // Display the node list
        if(isset($_POST["shownodelist"]))
        {

            echo "<p>Node list:<br />";
            echo "<textarea name=\"xmlnodelist\" style=\"width: 95%; height: 200px;\">";
            print_r($entries);
            echo "</textarea></p>";
        }

        
        // Display the source xml
        // Let PHP reformat it as it's rendered by PHP

        if(isset($_POST["showxml"]))
        {

            echo "<p>XML:<br />";
            echo "<textarea name=\"xmlsource\" style=\"width: 95%; height: 200px;\">";
            echo htmlentities($oSimpleXML->asXML());
            echo "</textarea></p>";
        }
    }

    
    // Print a bit of Javascript to toggle the values passed
    echo <<<SCRIPT
        <script type="text/javascript">
        function toggleVP()
        {
            var link = document.getElementById('toggleVP');
            var vpblock = document.getElementById('valuespassed');
            
            if(vpblock.style.display == "none")
            {
                vpblock.style.display = "block";
                link.innerHTML = "v Hide values passed";
            }
            else
            {
                vpblock.style.display = "none";
                link.innerHTML = "&gt; Show values passed";
            }
            
            return false;
        }
        </script>
SCRIPT
;
}

?>

</form>
<a href="privacy.htm">Privacy statement</a> | <a href="http://consent.live.com" target="_blank">Revoke permissions</a> | <a href="drop.zip">Source code</a>
</body>
</html>


Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
// GetData is used to get the XML from the Live-servers
// $dt = Delegation token
// $uri = URI to use
// $lid = Location ID, the user ID.

function getData($dt, $uri, $lid)
{

    $host = "livecontacts.services.live.com";
    $urisplit = split("://", $uri);
    $page = substr($urisplit[1], strlen($host));

    // Add the token to the header
    $headers = array
    (
        "Authorization: DelegatedToken dt=\"$dt\""
    );

    // I use cURL (www.php.net/curl) to get the information
    // Let's set up the request

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $uri);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_TIMEOUT, 60);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_USERAGENT, "Alex Media Windows Live Delegated Auth Sample Script");
    
    // Ready? Set? GO!
    $data = curl_exec($curl);

    // Get the info and close the connection
    $curlinfo = curl_getinfo($curl);
    curl_close($curl);

    
    // Have any errors occured? If so, print them.
    if($curlinfo["http_code"] == "401")
    {

        echo "<h2>The remote server refused the DT. Is it correct?</h2>";
        echo "<h3>Sometimes this error may occur. If you're sure everything is correct, try again.</h3>";
        return false;
    }


    if($curlinfo["http_code"] == "403")
    {

        echo "<h2>The remote server refused to give you this information. Are you sure you have selected the mode belonging to the requested offer (i.e. Contacts for Contacts.View)</h2>";
        return false;
    }

    
    if($curlinfo["http_code"] == "404")
    {

        echo "<h2>Woops... looks like you're trying to request something that isn't there. Are you sure the CID and LID are ok?</h2>";
        return false;
    }


    // If the code reaches this point, everything went well.
    return $data;
}


/* unfucked_base_convert is used to correctly convert the CID's to INT64 LID's
    Follows the syntax of base_convert (http://www.php.net/base_convert)
    Created by Michael Renner @ http://www.php.net/base_convert
    17-May-2006 03:24
*/

function unfucked_base_convert ($numstring, $frombase, $tobase)
{

    $chars = "0123456789abcdefghijklmnopqrstuvwxyz";
    $tostring = substr($chars, 0, $tobase);

    $length = strlen($numstring);
    $result = '';
    for ($i = 0; $i < $length; $i++) {
        $number[$i] = strpos($chars, $numstring{$i});
    }

    do {
        $divide = 0;
        $newlen = 0;
        for ($i = 0; $i < $length; $i++) {
            $divide = $divide * $frombase + $number[$i];
            if ($divide >= $tobase) {
                $number[$newlen++] = (int)($divide / $tobase);
                $divide = $divide % $tobase;
            }
elseif ($newlen > 0) {
                $number[$newlen++] = 0;
            }
        }

        $length = $newlen;
        $result = $tostring{$divide} . $result;
    }

    while ($newlen != 0);
    return $result;
}

?>
 

29/04/2008 11:06:00
Quote Anchor link
Misschien, als je zo graag alle code wilt plaatsen, wat dus niet hoeft, moet je je code effe tussen en plaatsen.
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.