domingo, 16 de febrero de 2014

Accessing Google Blogger from a Google App Engine Application

I have my portfolio, which is a Google App Engine Application. I want to access my blog and show some things from there (posts, comments, categories...). How can I do this? First of all, this blog runs on blogger.com which is owned by google. Googles allows to access blogger through the Blogger API, which defines a series of methods using the REST architectural style. Information about this API can be found here.

Of course, to be able to access these methods, the 'consumer' (in this case the portfolio app) should be authenticated and for some of them authorized. "Every request your application sends to the Blogger API must identify your application to Google" (see here). Lets see the case of getting the posts of a given public blog. For this case either the API key or an OAuthi 2.0 token must be provided. I will provide the API key.

One important thing to mention before: If the blog is public, why should the app be identified? because to be able to access the Blogger API, google authorizes each application. The Blogger API should be activated in the Services pane of the Google APIs Console.

Ok, to retrieve a list of posts from a given blog,  you can send a GET request to the POST collection URI:

https://www.googleapis.com/blogger/v3/blogs/2399953/posts?key=APP_KEY

To configure this kind of request, to set parameters and to parse the response is the google api java client very helpful. First step is to create a blogger object and to set the application name to it:

Blogger blogger = new Blogger.Builder(new UrlFetchTransport(), new JacksonFactory(), null).setApplicationName("ghlozanom").build(); 

With the blogger object, any specifi request to this API can be created, confiured and executed. At the end, a set of objects related to the Blog are there ready to be used, for example:


com.google.api.services.blogger.Blogger.Posts.List postsRequest; postsRequest = blogger.posts().list(BLOG_ID); PostList postList = postsRequest.setKey(API_KEY).execute()

This code snipped retrieves all the post entries for a given blog and a given application (identified with the APP_KEY).

martes, 11 de febrero de 2014

Portfolio and Blog Web Site

A pair of weeks ago I decided to created a portfolio web site. It is a Web application that runs on the Google App Engine with Java technology (Java + Servlets). It is available at ghlozanom.appspot.com and includes a personal info(profile, resume and portfolio) and a blog page.

Personal Info Page
The code for this application is available in GitHub.

For this application I am not using any web framework, everything (Form validation, parameters adquisition, user notifications,...) is done with servlets directly. The plan is to evaluate and integrate a good web framework.

To show messages to the user, noty, a jQuery Notification Plugin is used.
 
Example of User Notification
Based on GAE services, this application provides the following functionality:

  • Management of the user's main image (retrieves, stores and deletes) using GAE's blobstore.
  • Sending of messages in the contact form. A message is sent to the administrator and a confirmation message to the email address filled by the user.
 The next steps I plan to implement in this application is the integracion with the blogger API through the Google Data API using OAuth and Rest services, to use Objectify to interact with the datastore and the integration of a Web Framework.








MoneyHelper APP: JQuery Mobile and Google App Engine

Looking for the best way to host a web application with Java technology I found Google Application Engine(GAE). I started to read about it, found it very interesting and I decided to implement something. I matched this with the need to track my expenses and the idea behind Money Helper came to live. I wanted to see how was I investing (or should I say spending?) my money. Because I wanted to register every time euros were coming in and out of my pocket at the supermarket, a bar, ..., I thought it would be a good idea to enable access through the mobile. I searched for possibilities and found JQuery Mobile. JQM is a "HTML-5based user interface system... " (http://jquerymobile.com/).  With it I was able to create web pages that were accesible from my mobile phone. In my IPhone with Safari looks like this:

Money Helper main page

 Another screen to query expenses:


Expenses query

And a movements query page:

Movements

The code for this application is available at Github. It uses Google Data low-level API to work with data including entities management, queries and datastore transactions.