Buscando por la web e encontrado un script en javascript donde puniendo el correo electrónico y mi contraseña accedo a los contactos del messenger, pero el problema es que me lo extrae en javascript.
Me gustaria que me modificaran el script y que estos contactos tubiera un array donde yo poder tener mayor acceso.
Código PHP:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>MSN</title>
<link rel="stylesheet" href="Default.css" type="text/css" />
<script src="http://settings.messenger.live.com/api/1.0/messenger.js"
type="text/javascript" language="javascript"></script>
<script type="text/javascript" language="javascript">
var _signin = null;
function scriptMain()
{
var privUrl = 'http://' + document.domain + '/Privacy.htm';
var chanUrl = 'http://' + document.domain + '/Channel.htm';
_signin = new Microsoft.Live.Messenger.UI.SignInControl('signinframe', privUrl, chanUrl,
'es-ES');
_signin.add_authenticationCompleted(Delegate.create(null, authenticationCompleted));
}
function authenticationCompleted(sender, e)
{
_user = new Microsoft.Live.Messenger.User(e.get_identity());
_user.add_signInCompleted(Delegate.create(null, signInCompleted));
_user.signIn(null);
}
function signInCompleted(sender, e)
{
if (e.get_resultCode() === Microsoft.Live.Messenger.SignInResultCode.success)
{
_addressList = new Array(_user.get_contacts().get_count());
var enum1 = _user.get_contacts().getEnumerator();
while (enum1.moveNext())
{
var c = enum1.get_current();
var address = c.get_currentAddress();
address.get_presence().add_propertyChanged(Delegate.create(null, contact_Presence_PropertyChanged));
}
_user.get_presence().add_propertyChanged(Delegate.create(null, user_Presence_PropertyChanged));
displayUserInfo();
displayContacts();
}
_user.get_presence().add_propertyChanged(Delegate.create(null, user_Presence_PropertyChanged));
}
function contact_Presence_PropertyChanged(sender, e)
{
displayContacts();
}
//obtener informacion del usario
function displayUserInfo()
{
var userAddress = _user.get_address().get_address();
var userDispName = _user.get_presence().get_displayName();
document.getElementById('status').innerHTML = Enum.toString(Microsoft.Live.Messenger.PresenceStatus, _user.get_presence().get_status());
document.getElementById('userInfo').innerHTML = userDispName + ' (' + userAddress + ')';
document.getElementById('personalMessage').innerHTML = _user.get_presence().get_personalMessage();
}
//actualizar estado
function user_Presence_PropertyChanged(sender, e)
{
displayUserInfo();
}
//obtener lista de contactos
function displayContacts()
{
var sb = new StringBuilder('<div>Lista de Contactos</div>');
var enum1 = _user.get_contacts().getEnumerator();
var index = 0;
while (enum1.moveNext())
{
var c = enum1.get_current();
var address = c.get_currentAddress();
var status = Enum.toString(Microsoft.Live.Messenger.PresenceStatus, address.get_presence().get_status());
_addressList[index] = address;
if (address.get_presence().get_displayName() != '')
{
sb.append("<div><span><a href=\'javascript:createConv(" + index + ")\'>" + address.get_presence().get_displayName() + "(" + status + ")</a></span></div>");
}
else
{
sb.append("<div><span><a href=\'javascript:createConv(" + index + ")\'>" + address.get_address() + "(" + status + ")</a></span></div>");
}
index++;
}
document.getElementById('divContacts').innerHTML = sb.toString();
}
//se pasa el usario para iniciar conversacion
function createConv(index)
{
var newConv = _user.get_conversations().create(_addressList[index]);
var convId = _user.get_conversations().get_count();
switchConv(newConv.convId);
}
function conversation_collectionChanged(sender,e)
{
displayConversations();
}
function displayConversations()
{
convArray = new Array();
var sb = new StringBuilder('<p><b>Conversaciones Activas: (Para ver una conversación pulsar sobre el link):</b></p>');
var item = 0;
var enum1 = _user.get_conversations().getEnumerator();
while (enum1.moveNext())
{
var c = enum1.get_current();
convArray.push(c + ":" + item);
if (c.get_closed())
continue;
sb.append(convLink(c, item));
sb.append("<hr />");
item++;
}
document.getElementById('divConversations').innerHTML = sb.toString();
}
//para enviar mensajes
function sendMsg()
{
var txtMessage = document.getElementById('txtMessage');
var messageText = txtMessage.value;
var message = new Microsoft.Live.Messenger.TextMessage(messageText, null);
if (_user)
{
_conv.sendMessage(message, null);
}
displayMsg(message);
txtMessage.value = '';
txtMessage.focus();
}
function displayMsg(message)
{
var elMsg = message.createTextElement();
var txtConv = document.getElementById('txtConv');
var userName = "";
if (message.get_sender().get_presence().get_displayName() != null)
userName = message.get_sender().get_presence().get_displayName();
else
userName = message.get_sender().get_address();
txtConv.appendChild(document.createTextNode(userName + ' says: '));
txtConv.appendChild(elMsg);
txtConv.appendChild(document.createElement('br'));
}
//muestra la conversacion seleccionada
function recvMsg(sender, e)
{
var message = e.get_message();
displayMsg(message);
document.getElementById('msgLastRecv').innerText = 'Último mensaje recibido: ' + _conv.get_history().get_lastReceived().toString();
}
function convLink(c, item)
{
var roster = c.get_roster();
var enum1 = roster.getEnumerator();
var names = new Array();
while (enum1.moveNext())
{
var dispName = enum1.get_current().get_presence().get_displayName();
var dispEmail = enum1.get_current().get_address();
if (dispName !== '')
{
names.push(dispName);
}
else
{
names.push(dispEmail);
}
}
var sb = new StringBuilder();
sb.append('<a href=\"javascript:switchConv(' + item + ')\">');
if (c == _conv)
sb.append('<b>');
sb.append(names.join(', '));
if (c == _conv)
sb.append('</b>');
sb.append('</a>');
sb.append(' ');
sb.append('<a href=\"javascript:closeConv(' + item + ')\">');
sb.append('close</a>');
return sb.toString();
}
function switchConv(id)
{
var c = _user.get_conversations().get_item(id);
if (c)
{
if (_conv)
{
_conv.remove_messageReceived(_convSink);
}
_convSink = Delegate.create(null, recvMsg);
_conv = c;
_conv.add_messageReceived(_convSink);
removeChildrenFromNode('txtConv');
var hist = c.get_history();
var histEnum = hist.getEnumerator();
while (histEnum.moveNext()) {
displayMsg(histEnum.get_current());
}
document.getElementById('btnSend').disabled = false;
}
displayConversations();
txtMessage.focus();
}
//cierra la conversacion selecionada y borra todos los textos de la ventana de conversacion
function closeConv(id)
{
var c = _user.get_conversations().get_item(id);
convArray.splice(id, 1);
c.close();
if (c == _conv)
{
removeChildrenFromNode('txtConv');
}
displayConversations();
if(_user.get_conversations().get_count() == 0)
document.getElementById('btnSend').disabled = true;
}
function removeChildrenFromNode(id)
{
var node = document.getElementById(id);
if(node == undefined || node == null)
{
return;
}
var len = node.childNodes.length;
while (node.hasChildNodes())
{
node.removeChild(node.firstChild);
}
}
</script>
</head>
<body onLoad="scriptMain()">
<div id="msgr">
<table>
<tr>
<td><div id="signinframe"></div></td>
</tr>
<tr>
<td>
<div>
<span><b>Información del Usuario: </b></span>
<span id="userInfo"></span>
</div>
</td>
</tr>
<tr>
<td>
<div>
<span><b>Estado: </b></span>
<span id="status"></span>
</div>
</td>
</tr>
<tr>
<td>
<div id="setPersonalMessage">
<span><b>Mensaje Personal: </b></span>
<span id="personalMessage"></span>
</div>
</td>
</tr>
<tr>
<td>
<div id="divContacts">
</div>
</td>
</tr>
<tr>
<td>
<div id="sendMessage">
<span><b>Mensajes:</b></span>
<p id="contactLabel"></p>
<p id="msgLastRecv"></p>
<div id="txtConv"></div>
<br />
<input id="txtMessage" type="text" /><br />
<input onClick="sendMsg()" id="btnSend" type="submit" value="Enviar" disabled="disabled" />
</div>
</td>
</tr>
</table>
</div>
</body>