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
<?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="<?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="<?php echo $_REQUEST["dt"]; ?>" /></td>
</tr>
<tr>
<td>CID in HEX:</td>
<td><input type="text" name="cid" value="<?php echo $_REQUEST["cid"]; ?>" /></td>
</tr>
<tr>
<td>Verbosity:</td>
<td><input type="checkbox" name="shownodelist" id="shownodelist" <?php echo $checkboxShowNodeList; ?>/><label for="shownodelist">Show Node List</label><br />
<input type="checkbox" name="showxml" id="showxml" <?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" <?php echo $radioContacts; ?> /><label for="contacts">Contacts</label><br />
<input type="radio" name="mode" value="invite" id="invite" <?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>
<?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\">> 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 = "> 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>
<?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;
}
?>