Pages

Showing posts with label opensocial. Show all posts
Showing posts with label opensocial. Show all posts

Develop an Open social application in 60 seconds

Open social application development made a giant leap.An eclipse plugin that eases the development of opensocial apps.I have written about open social applications before and I had a chance to work on it.Apache shindig is the initiative to develop a SNS container for application development and testing.I would say OSDE plugin developed by Yoichiro Tanaka rocks!! It uses apache shindig and hibernate for a dynamic development, so the developer can create a single application for different data models.As apache shindig provides java REST support, the application development will become more extensible.The database packaged with the plugin is H2(a Java SQL database).Before this plugin came, we had to develop and run the applications iniside a sandbox which was really tiring.This plugin has features of wizard like development for both javascript widgets and Java REST client applications.We can have our own custom social data which can be easily persisted due to the excellent plugin architecture.So I tried to develop a simple application ...

After the plugin is installed create a new OSDE project


Specify the gadget.xml and the API specs etc


For the development we need to run the apache shindig in the background.



To have a custom social data create people and add relationships between them.





Write a simple gadget ... (templates can be generated by the plugin if needed)
----src-------


<?xml version="1.0" encoding="UTF-8" standalone="yes"?><module><moduleprefs author_email="harisa@pramati.com" description="A friendly os app" title="Friends"><require feature="opensocial-0.8"><require feature="dynamic-height"></moduleprefs><content view="canvas" type="html">

<!-- Fetching People and Friends -->
<div>
<button onclick='fetchPeople();'>Fetch</button>
<div style="margin-left:20px;">
I am ... <span id='viewer' style="background-"></span><br/>My friends are ...
<ul id='friends' style="margin-top:5px;list-style:none;margin-left:75px;"></ul>
</div>
</div>
<script type='text/javascript'>
function fetchPeople() {
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), 'viewer');
var params = {};
params[opensocial.IdSpec.Field.USER_ID] = opensocial.IdSpec.PersonId.VIEWER;
params[opensocial.IdSpec.Field.GROUP_ID] = 'FRIENDS';
var idSpec = opensocial.newIdSpec(params);
req.add(req.newFetchPeopleRequest(idSpec), 'friends');
req.send(function(data) {
var viewer = data.get('viewer').getData();
document.getElementById('viewer').innerHTML = viewer.getId();
var friends = data.get('friends').getData();
document.getElementById('friends').innerHTML = '';
friends.each(function(friend) {
document.getElementById('friends').innerHTML += '<li>&#187;' + friend.getId() + '</li>';
});
gadgets.window.adjustHeight();
});
}
</script>

----src ends---------

Run the application

Gadget --->


Cool... Its simple. But this plugin will be really useful when we develop the complex applications and aiming for multiple containers supporting open social api.

More ....
opensocial-development-environment
screencasts
youtube

A sample iWidget



Finally I got iWidget published :) A simple one that fetches my friend feed.Click on "View" button to fetch the data. The interesting thing is that this "patent-pending" Write Once Run Anywhere widget platform will provide the users publish their widget to Facebook,Myspace,igoogle,netvibes,widgetbox,clearspring as of now.Others like hi5,orkut,gigya are on the way. I think this platform could become a good tool for opensocial gadget developers.

A gmap opensocial gadget - Voila


Recently I started working on an opensocial application platform based on java and php.Previous posts on opensocial and apache shindig is written while I am  involved in the development. The open social applications allow to share the data between different sites and social networks.I developed a sample gadget to mashup data from our social application platform with Google maps, I named it "Voila".Using this one can save the last location you been and share it with friends.Also you can view your friends shared locations.One can play around for those who don't carry a location based device.It uses Opensocial's persistence feature. 



I made another gadget which uses a job site's service .The gadget named "Empleo" is intelligent , it automatically gathers owner's job interests and update each time .Also he can go for search tool embedded within it.Another thing I did was to integrate Tell-a-Friend WOMM widget with an opensocial gadget.So the user can tell a friend about a job of him using any service.

Empleo Screenshots viewed inside preview window .



Debug open social gadgets : Error codes

I was playing around with Apache shindig to develop a simple open social application.
I find it easy to use the error codes available in open social specification.Use this sample gadget for testing purposes.In the specification http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.ResponseItem.getErrorCode

it says like to get error code from getErrorCode function. Its returning an enumeration.So its easy to get error codes from Error class.I tried for response.getErrorCode().. hopeless .. its undefined while response.hadError() was working !! I think spec document should be clear with examples ...mmm try the code ..





<script type="text/javascript" >
function getData() {
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('VIEWER'), 'viewer');
req.send(callback);
}


function callback(response){


if(!response.hadError()){
alert("Success");
var html = "Test OK"
document.getElementById('message').innerHTML = html;

}else {
alert(response.getErrorMessage());
var viewer_resp_item = response.get('viewer')
switch(viewerresp.getErrorCode())
{
case opensocial.ResponseItem.Error.INTERNAL_ERROR :
/*The request encountered an unexpected condition that prevented it from fulfilling the request*/
alert('There was an error on the server.');
break;
case opensocial.ResponseItem.Error.UNAUTHORIZED :
/*The gadget does not have access to the requested data.*/
alert('There was a permissions issue: the app is not allowed to show the data.');
break;
case opensocial.ResponseItem.Error.BAD_REQUEST :
/*The request was invalid.Parameters are wrong etc.*/
alert('There was an error in the Container.');
break;
case opensocial.ResponseItem.Error.FORBIDDEN :
/*The gadget can never have access to the requested data.*/
alert('The Container was unable to contact the server.');
break;
case opensocial.ResponseItem.Error.NOT_IMPLEMENTED :
/*This container does not support the request that was made.
Different version of implementations*/
alert('did not implement this particular OpenSocial interface.');
break;
case opensocial.ResponseItem.Error.LIMIT_EXCEEDED :
/*The gadget exceeded a quota on the request.*/
alert('Limit exceeded.');
break;


}

}
}


gadgets.util.registerOnLoadHandler(getData);

</script>





Cool opensource projects associated with Apache Shindig

There are a lot open source initiative happening for the open social application development.Apache shindig is an incubator project helps to develop opensocial containers .

Guice

The dependency injection framework from Google.It helps in developing custom handlers in shindig.It takes creating instances in the form of Services from the Application client code and the Dependency between the Clients to its Services is automatically injected through some easy injection configuration mechanism.
http://code.google.com/p/google-guice/

Apache commons

The popular resusable components.
http://commons.apache.org/
-Lang
Extends java.lang functionality
http://commons.apache.org/lang/
-Betwixt
Maps java beans to XML
http://commons.apache.org/betwixt/
-Codec
For encoding decoding algorithms (base64 etc) utility.
http://commons.apache.org/codec/

Oauth

The security protocol.I have written about oauth here
For java.
http://oauth.googlecode.com/svn/code/java/core/

JSON

The javascript data interchange objects.
http://json.org/

Joda Time

Replaces java date and time.
http://joda-time.sourceforge.net/

Abdera

Implementing ATOM protocol and syndication.Its all about data in google..

http://incubator.apache.org/abdera/

Caja

Caja (pronounced ka-ha) makes it possible to run third-party JavaScript alongside existing code. Mechanism for javascript security.
http://code.google.com/p/google-caja/

Maven

The popular build tool.Commonly used project management tool for open source projects.Build,manage dependencies,update and so on.Very flexible.It appear as many things ..
http://maven.apache.org/

Jetty is used to run sample applications provided with shindig.

ICU4j

For internationalization.
http://www.icu-project.org/



Simal - Integrating social semantic nature of web to open source projects


Open source projects are becoming more prominent and powerful due to the web 2.0 / 3.0 revolution.There are mammoth number of projects get huddled in the web.Sites like sourceforge,freshmeat etc have thousands of open softwares cataloged in them.There are projects undertaken by universities and academicians.Many developers around the world work on various technologies .What if socialization is happening to the project endeavors ? How to integrate and share information of multiple projects around the web ?

Simal is a tool for building and tracking projects and the people involved in those projects.It is a framework for building project registry.Meta-data data models like RDF and document languages like XML do provide a solid foundation for cataloging mechanisms.The catalogs can be generated from RDF documents maintained and hosted by the projects themselves.This entry contains a description of what the project is doing, team members, community's structure, deliverables, etc.By exposing such data it is possible for interaction between related projects.The project catalog is built by importing Description of a Project (DOAP) files from projects.DOAP have an RDF vocabulary.

The DOAP for the project looks like this

The DOAP project design is explained by Edd Dumbill here , here , here.

The RDF semantics is used to build a community like feature.It can use the RSS feeds (trac/wiki changes,version control feeds,mailing list feeds etc) from the project and aggregate it.It could be a sort of friendfeed.The bugs,changes,their solutions etc can be updated among various projects.

A very interesting thing I noted is the addition of FOAF into the vocabulary.FOAF allows groups of people to describe social networks without the need for a centralized database.The Person Browser in their sample demo shows the implementation of the feature.Simal has REST API providing a high level means of accessing the data stored in the registry.

The integration of OpenSocial API and gadgets availability can make the application more widespread.The Simal Web module provides an open social container.Simal uses Shindig which is a refernce implementation of Open Social Standard.

Simal is utilizing the social semantic nature of web (termed web 3.0 ?) to make the open source revolution more powerful.

What about Simal used in large software companies ? Project repository cataloging that could give information about projects,people team, their social networks,projects done with other organizations.Simal will become a powerful utility in developing next generation project management and enterprise applications.

See demo