Sunday, September 18, 2011

First Google Plus Project in java

Few days back google has launched its google plus api. I Thought to have some hands on over that.
It pretty simple to create first google plus application. But its a very limited api. Hope more features will be released/added soon.

Now lets get into first google plus applicaion for java
I am gonna do this without any authentication of the user. (Yes thats possible is google plus, for public data only.)

            Plus plus = new Plus(new NetHttpTransport(), new GsonFactory());
            plus.setKey(YOUR_API_KEY);
 
            Person profile = plus.people().get(USER_ID).execute();
   System.out.println(profile.getDisplayName());
 
            List list = plus.activities().list(USER_ID, "public");
   list.setMaxResults(Long.parseLong("50"));
 
            ActivityFeed feed = list.execute();
 
                while (feed.getItems() != null) {
    for (Activity activity : feed.getItems()) {
    System.out.println(activity.getPlusObject().getContent());
    }    
   }

This is simple application to get the Displya name of the user and the list of public feeds from his/her stream.
1. commons-codec-1.3.jar
2. commons-logging-1.1.1.jar
3. google-api-client-1.5.0-beta.jar
4. google-http-client-1.5.0-beta.jar
5. google-oauth-client-1.5.0-beta.jar
6. gson-1.6.jar
7. guava-r09.jar
8. httpclient-4.0.3.jar
9. httpcore-4.0.1.jar
10. jackson-core-asl-1.6.7.jar
11. jsr305-1.3.9.jar
12. junit-4.8.2.jar
13. libplus.jar
14. protobuf-java-2.2.0.jar
15. xpp3-1.1.4c.jar

Soon I'll be posting how to get authenticated will google plus api.

No comments:

Post a Comment