User Tools

Site Tools


java:miningthesocialweb

This is an old revision of the document!


Mining the social web, 2nd edition

Introduction

I'm reading the book “Mining the social web, 2nd edition”. Look how cute it is:

The book gives a deep insight of how to exploit data from social websites, and it's a topic I am quite interested. However, the recipes are in python, but I want to make my own recipes in java. This page is for register my achievements (if any) and notes, because there are tons of link that might be interested or worth reading.

Twitter

The first chapter of the book deals with Twitter. To make my own java excursion into the topic, I've read some things.

Pick the libraries

Ive selected those libraries for my access to Twitter with java:

Why this libraries?? The process I've followed is to watch some projects in GitHub I was interested in and follow the projects: if there were messages, add one point. Then I've looked to the readme page of the project, and I was pleased to to read in the case of Scribe that this library has plenty of examples of a vast collection of social networks, so I thought it was nice to have half of the work done.

You may also need one library for the service Yahoo Geoplanet because it's needed to locate the trending topics by location id.

My first code

It is very hard to program with Twitter4J or even Scribe because there is no documentation available, so most of the time you will be trying to guess what's the object/method you need to instantiate to go to the next step.

Because I was so lost in the beginning, I've decided to follow simple goals at a time, mimicking the different steps of the book. Here are my steps:

Basic Object

I've created a basic to hold all my examples:

	private ConfigurationBuilder cb;
	private TwitterFactory tf;
	private Twitter twitter;
 
	public Examples()
	{
		// creating of the Twitter object
        cb = new ConfigurationBuilder();
 
        cb.setDebugEnabled(true)
            .setOAuthConsumerKey("EVrq1ZbUzRKfpRAvSxG1bg")
        .setOAuthConsumerSecret("oYBr1c4PHf6zh6UXDslO4ybTlZjjNGLFjsVhGi3F98")
        .setOAuthAccessToken("53728242-ch8muiYjotvrk5a8nEUypaiMUOVEYysGZ7LAIXI23")
        .setOAuthAccessTokenSecret("4gENWdtrVIR1x1LAju5J5on46pkxdJ4XGB64cI29g9uzm");
 
        tf = new TwitterFactory(cb.build());
        twitter = tf.getInstance();
 
	}
 
	public Twitter getConfiguredTwitter()
    {
        return twitter;
    } // sendDirectMessage
 
 
	public void getHomeTimeLine() throws TwitterException
	{
		  List<Status> statuses = twitter.getHomeTimeline();
		  for( Status status : statuses )
			  System.out.println( status.getUser().getName() + ": " + status.getText() );
	}

Oauth libraries in java

Learning path for Twitter

Apart from the book, which I encourage to read even you are not keen on python, these are my readings:

Introduction to OAuth in plain english

If you are like me, probably OAuth is a technology that doesn't seem clear to you. I encourage you to navigate and read about this topic. Moreover, this is the base of many “Sign in with Twitter”, “Sign in with facebook” and the like.

Facebook

http://restfb.com/

RestFB is a simple and flexible Facebook Graph API and Old REST API client written in Java. It is open source software released under the terms of the MIT License.

java/miningthesocialweb.1390691566.txt.gz · Last modified: 2022/12/02 22:02 (external edit)