By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,520 Members | 1,271 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,520 IT Pros & Developers. It's quick & easy.

Getting status from window live presence api in interval of 2mins

P: 26
Hi All
I have a scenario where I need to call windows live presence api in interval of 2 to continuously update presence status of an user on my webpage without postback.I went through this link, I just want whatever is mentioned here but top on that ability to call this API after regular interval
http://msdn.microsoft.com/en-us/library/bb936689.aspx




Thanks
Jalaj
Aug 19 '08 #1
Share this Question
Share on Google+
9 Replies


acoder
Expert Mod 15k+
P: 16,027
Use window.setinterval().
Aug 19 '08 #2

P: 26
Hi
I am bit new to javascript.

Also I m calling a link which is in altogether different domain.So I don't know how
to achieve this. Anycode sample would be of great help
Aug 20 '08 #3

acoder
Expert Mod 15k+
P: 16,027
Have you managed to get any information back while using the API? Can you show the code that you've tried so far.
Aug 20 '08 #4

P: 26
Have you managed to get any information back while using the API? Can you show the code that you've tried so far.
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2.  
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5.     <title>Untitled Page</title>
  6. </head>
  7. <body>   
  8.    <div id="innerFrame"></div>
  9.  
  10.    <script type="text/javascript" language="javascript">  
  11.  
  12.    function showpresence(presence)
  13.    {
  14.  
  15.       var innerFrame = document.getElementById('innerFrame');         
  16.       var statusIcon = document.createElement('img');
  17.       statusIcon.style.border = 'none';
  18.       statusIcon.src = presence.icon.url;
  19.       statusIcon.width = presence.icon.width;
  20.       statusIcon.height = presence.icon.height;
  21.       statusIcon.alt = presence.statusText;
  22.       statusIcon.title = presence.statusText;
  23.  
  24.       var displayName = document.createElement('span');
  25.       displayName.style.fontFamily = 'Tahoma, Verdana, sans-serif';
  26.       displayName.style.fontSize = '9pt';
  27.       displayName.title = presence.displayName;
  28.  
  29.       var statusText = document.createElement('span');
  30.       statusText.style.fontFamily = 'Tahoma, Verdana, sans-serif';
  31.       statusText.style.fontSize = '9pt';
  32.       statusText.title = presence.statusText;
  33.  
  34.       var br = document.createElement('br');
  35.  
  36.       innerFrame.appendChild(statusIcon);
  37.       innerFrame.appendChild(br);
  38.       innerFrame.appendChild(displayName);
  39.       innerFrame.appendChild(br);
  40.       innerFrame.appendChild(statusText);
  41.  
  42.       if ((displayName.innerText !== undefined)&&(statusText.innerText !== undefined))
  43.       {
  44.          displayName.innerText = presence.displayName;
  45.          statusText.innerText = presence.statusText;
  46.       }
  47.       else if ((displayName.textContent != undefined)&&(statusText.textContent !== undefined))
  48.       {
  49.          displayName.textContent == presence.displayName;
  50.          statusText.textContent == presence.statusText;
  51.       }
  52.    }
  53.    </script>
  54.    <script type="text/javascript" language="javascript"
  55. src="http://messenger.services.live.com/users/670D6EA19275AD0B@apps.messenger.live.com/presence/?cb=showpresence">
  56.    </script>
  57.  
  58.     <p>
  59.  
  60. </body>
  61. </html>
This is the version of code which is also there at msdn
http://msdn.microsoft.com/en-us/library/bb936688.aspx

Now this code gets users presence .I want to get user's presence status in interval of 2 mins without refreshing my page.
Aug 21 '08 #5

acoder
Expert Mod 15k+
P: 16,027
The script just returns a function call, so you need to put that in a function and call it every two minutes, e.g.:
Expand|Select|Wrap|Line Numbers
  1. function showNew() {
  2.     var script = document.createElement("script");
  3.     script.type="text/javascript";
  4.     script.src="http://messenger.services.live.com/users/670D6EA19275AD0B@apps.messenger.live.com/presence/?cb=showpresence";
  5.     document.body.appendChild(script);
  6. }
Call showNew() using setInterval every 120 seconds.
Aug 21 '08 #6

P: 26
Thanks a ton .That's what I wanted .
Only One question more
creating script element again will create any issue??

when I went to see the size of Iexplore.exe which was running this particular code,its size was continuosly increasing. AnyOther solution would be fine,otherwise this will also do
Aug 21 '08 #7

acoder
Expert Mod 15k+
P: 16,027
Give the script tag an ID and then try setting its src. If not that, then try replacing the script and see if that makes a difference.
Aug 21 '08 #8

P: 26
It worked :)
Thanks again
Aug 22 '08 #9

acoder
Expert Mod 15k+
P: 16,027
You're welcome. Glad it's working.
Aug 22 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.