Yesterday I saw that Google has released Google+ API, so I started to played with in my favorite part of the day: the night!
For now Google has published only public APIs that allow you to retrieve user’s informations and his activities list, all API are made in RESTful and JSON that are so easy to add in your project.
When Google will release next APIs, I hope soon, you can consume them with an oAuth 2.0 authentication, like Facebook.
I made a simple example to retrieve data from my Google+ profile in Actionscript for Android, you can download the source files directly from here.
If you want to play with Google+ API, first of all you have to request your Google+ API key; to do that go to Google API console and activate Google+ service, then in the details page you can find your key.
Google+ RESTful services get us a JSON response, to read it in your Flash/Flex application remember that you need as3corelib that have the JSON deserializer, for example you can push in a generic Object all data retrieved from Google+ service or if you prefer you could create a Value Object that it could be more useful.
In this case I decode directly in a generic Object, like you can see in this code snippet:
var data:Object= JSON.decode(dataToRead, true);
then now you can easily access to informations:
var icon:String = data.image.url; var name:String = data.displayName; var tagline:String = data.tagline; var description:String = data.aboutMe;
Another easy feature that you can add in your Google+ application is a static image of the map, like in your web page, using Google Maps Static API.
You can easily make a query to Google Maps passing in GET params like: the dimension of image, the location and the zoom; you can also add more params that you find in the docs of Google Maps Static API.
Here a code sample to add this feature in your Flash application, in those line I request for an image with width 480px, height 200px, with roadmap skin and with a zoom of 15x:
var mapLoader:Loader = new Loader(); //city is a variable with the name of the place that you have to retrieve. mapLoader.load(new URLRequest("http://maps.googleapis.com/maps/api/staticmap?center=" +city+"&zoom=15&size=480x200&maptype=roadmap&sensor=true")); mapLoader.y = this.stage.stageHeight - 200; addChild(mapLoader);
Like you can see work with those APIs are pretty easy, so now we have to wait for final release and then we can start to create our Google+ integration with the Flash Platform.