This example uses YQL to get a user’s Messenger buddy list, including their image and nickname.
YQL table: yap.messenger.buddy
Note: If you are not already logged in to Yahoo!, you will be prompted to log in or create a new Yahoo! account.
The Create New App page appears.
Fill in the fields as follows:
App Title: Enter “Messenger Buddy List”.
This is the title of the App as it will appear in the Galleries.
App Content: Select “External”.
App Content URL: Enter the hosted URL “http://www.yap-apps.com/sample/Messengerbuddylist.html“
User Signin: Select “Required”.
HTTP Method: Select “GET”.
Dimensions: Enter “960” for Width, and “600” for Height. This is the default.
Description: Enter “Messenger Buddy List”
This is the description of your app Gallery as it will appear to users.
Click the “Create App” button. The Edit App page appears.
The Preview page appears:
The Hosted HTML file contains a call to YQL asking for the messenger buddy list.
YQL
select guid, image.imageUrl, name.nickname from yap.messenger.buddy where guid=me
HTML
<html>
<body>
<div id="result-cell"></div>
</body>
<script type="text/javascript">
var qry;
var output;
try {
function request() {
// prepare array with key value pair
var params = {};
params[gadgets.io.RequestParameters.AUTHORIZATION] =
gadgets.io.AuthorizationType.SIGNED;
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
// select guid, image.imageUrl, name.nickname from yap.messenger.buddy
// where guid=me
var url = "http://query.yahooapis.com/v1/yql?q=select%20guid%2C%20
image.%20imageUrl%2C%20
name.%20nickname%20%20
from%20yap.messenger.buddy%20
where%20guid%3Dme&format=json";
gadgets.io.makeRequest(url, response, params);
};
function response(obj) {
qry = obj;
par = JSON.parse(qry.data);
c = par.query.results.contact;
for(var i=0;i< 10;i++)
{
var guid = c[i].guid;
var image = c[i].image.imageUrl;
var name = c[i].name.nickname;
output = output +
'<ul style="list-style-type:none">
<li>
<img src=' +image+' width="100" height="100">
</li>'+'<li>
<strong>GUID: </strong>' + guid + '</li>' + '<li>
<strong>NAME: </strong>' + name+ '</li>
</ul>';
}
document.getElementById("result-cell").innerHTML = output;
};
request();
}
catch(e) {
document.getElementById("result-cell").innerHTML = e.toString();
}
</script>
</html>