Having your blog display your AIM away message using the WIM API is a pretty simple operation. Follow these steps to get it up and running:
- Visit http://developer.aim.com/manageKeys.jsp and grab an API key.
- In the
<head>of your document, paste this line:<script type="text/javascript" src="http://o.aolcdn.com/aim/web-aim/aimapi.js"></script>
- Next, paste this code into your document directly after the previous
<script>element:<script type="text/javascript"> // Register a callback for the getPresenceInfo transaction AIM.params.callbacks.getPresenceInfo = ["awayMessageWidget.displayAwayMessage"]; var awayMessageWidget = { // Our init function, called from the window's onload event. init: function() { // Our API key. Be sure to change this to your own AIM.params.wimKey = "sc1OCxN4ASAnSDj1"; // Call the getPresenceInfo transaction AIM.transactions.getPresenceInfo(); }, // This function is the callback for our transaction. It takes the json response from the host as its argument displayAwayMessage: function(json) { // Only do stuff if the back-end tells us everything is Ok if(json.response.statusCode==200) { // Only do stuff if the status of the user is "away" if(json.response.data.users[0].state == "away") { // grab the away message from the response and stick it in the "myAwayMessage" element. document.getElementById("myAwayMessage").innerHTML = "My away message: " + json.response.data.users[0].awayMsg; } } } } // attach the init function to the onload event of the window window.addEventListener?window.addEventListener("load",awayMessageWidget.init,false):window.attachEvent("onload",awayMessageWidget.init); </script> - Finally, paste this line into the
<body>of your document where you want your away message to appear. Replace YourScreenName with your own AIM screen name.<div id="myAwayMessage" class="AIMPresenceWidget YourScreenName"></div>
Note: If you aren't away or the backend returns an error code, nothing will be displayed.
