User Tools

Site Tools


java:miningthesocialweb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
java:miningthesocialweb [2014/01/26 00:16] rlunarojava:miningthesocialweb [2022/12/02 22:02] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Mining the social web, 2nd edition ======+====== Mining the social web, 2nd edition in Java ======
  
 ===== Introduction ===== ===== Introduction =====
Line 49: Line 49:
                    
         cb.setDebugEnabled(true)         cb.setDebugEnabled(true)
-            .setOAuthConsumerKey("EVrq1ZbUzRKfpRAvSxG1bg") +            .setOAuthConsumerKey("HERE-GOES-YOUR-CONSUMER-KEY") 
-        .setOAuthConsumerSecret("oYBr1c4PHf6zh6UXDslO4ybTlZjjNGLFjsVhGi3F98") +        .setOAuthConsumerSecret("HERE-GOES-YOUR-CONSUMER-SECRET") 
-        .setOAuthAccessToken("53728242-ch8muiYjotvrk5a8nEUypaiMUOVEYysGZ7LAIXI23") +        .setOAuthAccessToken("HERE-GOES-YOUR-ACCESS-TOKEN") 
-        .setOAuthAccessTokenSecret("4gENWdtrVIR1x1LAju5J5on46pkxdJ4XGB64cI29g9uzm");+        .setOAuthAccessTokenSecret("HERE-GOES-YOUR-ACCESS-TOKEN-SECRET");
                      
         tf = new TwitterFactory(cb.build());         tf = new TwitterFactory(cb.build());
Line 95: Line 95:
     }     }
 } // exploringTrendingTopics } // exploringTrendingTopics
-<code>+</code>
  
 +=== Get trending topics by country ===
 +
 +It's possible that not all the trending topics can be consulted. For instance, I've tried with other locations (cities in Spain) and it doesn't work. It does work searching for the trending topics of Spain, for instance. Would work searching for little countries like Andorra or Cittá del Vaticano?
 +
 +However, you should register in [[http://developer.yahoo.com/geo/geoplanet/|Yahoo! Geoplanet]] to get the ID for Spain or other country.
 +
 +<code java>
 +/**
 + * Example of page 16, bullet 1.3.3
 + */
 +public void exploringTrendingTopics() throws TwitterException, GeoPlanetException
 +{
 +
 +    GeoPlanet g = new GeoPlanet("PUT-HERE-YOUR-PROJECT-CONSUMER-KEY");
 +    PlaceCollection places = g.getPlaces("Spain");
 +
 +    // take only the first ocurrence,
 +    // who is the country
 +    Place spain = places.get(0);
 +    
 +    if( spain == null )
 +        return;
 +    
 +    Trends trends = twitter.trends().getPlaceTrends( (int) spain.getWoeId() );
 +    
 +    for( Trend trend : trends.getTrends() )
 +    {
 +          System.out.println( trend.toString() );
 +        System.out.println( "Trend: " + trend.getName() );
 +        System.out.println( "  Url: " + trend.getURL() );
 +    }
 +} // exploringTrendingTopics
 +</code>
  
 ===== Oauth in Java: links to investigate ===== ===== Oauth in Java: links to investigate =====
java/miningthesocialweb.1390691811.txt.gz · Last modified: 2022/12/02 22:02 (external edit)