I am creating a new gadget (using API Gadgets and API OpenSocial)
that:
- reads Orkut data from external server (e.g. phone no. / osid /
videoid) using make.io.request.
- reads new Orkut user info (register a cel phone) dialed by the user
on the keyboard
and then sent it to external format via HTTP (HTML encapsulated in XML
format).
The file to be read from server has the following format (XML):
<ApplicName>
<Messages>
<Start>Title1</Start>
<Tel>phone1</Tel>
<OsId>osid1</OsId>
<videoId>videoID_1</videoId>
<Start>Title2</Start>
<Tel>phone2</Tel>
<OsId>osid2</OsId>
<videoId>videoID_2</videoId>
</Messages>
</ApplicName>
How a gadget can read XML data above from external server (using
make.io.request from API gadget
and then be displayed in HTML page?
Can HTML.push be used for this purpose?
Here follows some useful parts of gadget:
// Function that is invoked whenever user is registered or logs
into application:
function request() {
var idspec = opensocial.newIdSpec({ "userId" : "OWNER",
"groupId" : "FRIENDS" });
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER),
"get_owner");
req.add(req.newFetchPeopleRequest(idspec), "get_friends");
req.send(response);
};
// Function that receives and formats data from the server:
function response(dataResponse) {
var owner = dataResponse.get('get_owner').getData();
var friends = dataResponse.get('get_friends').getData();
var html = 'Friends of ' + owner.getDisplayName();
html += ':<br><ul>';
friends.each(function(person) {
html += '<li>' + person.getDisplayName() + '</li>';
});
html += '</ul>';
document.getElementById('message').innerHTML = html;
};
function sendPostRequest(){
var params = {};
var postdata = {
data1_phone,
data2_osid,
data3_videoid,
}
params[gadgets.io.RequestParameters.METHOD] =
gadgets.io.MethodType.POST;
params[gadgets.io.RequestParameters.POST_DATA] =
gadgets.io.encodeValues(postdata);
var url = GLOBAL_BASE_URL;
gadgets.io.makeRequest(url, responsePost, params);
};
Thanks.
--
You received this message because you are subscribed to the Google Groups
"iGoogle Developer Forum" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/Google-Gadgets-API?hl=en.