2. OAuth
âą Twitter needs authentication
âą Many SNS rely on OAuth to grant access to API features
âą OAuth is a security protocol for Web applications.
â Security for REST and XML-RPC services.
â Signed HTTP Requests
â Safe, Password-less Token Exchange
âą Actors: User / ServiceProvider / Consumer
ESWC 2014 Social Web: Where are the Semantics? 2
3. Twitter API
âą General ideas
â Limit on the requests, in a per 15-min basis
â Each Tweet as an ID
â Objets: Tweets, Users, Entities (hashtags, photos, urlsâŠ), Places
âą Capabilities
â Timelines (of user mentions, retweets, etc.)
â Tweets (given ID, retweet, etc.)
â Search (shown this in this tutorial)
â Friends & Followers, Direct Messages, Favourites, TrendsâŠ.
â Places & Geo
â Users
â Streaming (the most powerful!)
ESWC 2014 Social Web: Where are the Semantics? 3
4. 1.- Obtain a Twitter account, register application
ESWC 2014 Social Web: Where are the Semantics? 4
1. Register a new Twitter account (or use yours)
2. Register as a developer: https://dev.twitter.com/
3. Register your new application
5. 2. â Obtain your credentials
4. See your API keys and generate a token
ESWC 2014 Social Web: Where are the Semantics? 5
6. To set up your projectâŠyou need two files
âą TwitterDataCollector.java contains the code that you need to use
the Twitter REST API
âą twitterCollector.properties. This is the properties file that you need
to set up. You need to add:
â consumerKey = (the data obtained in the step before)
â consumerSecret = (the data obtained in the step before)
â accessToken = (the data obtained in the step before)
â accessTokenSecret = (the data obtained in the step before)
ESWC 2014 Social Web: Where are the Semantics? 6
7. TwitterDataCollector
âą You can find the code:
â In the code folder of the given USB
â https://gist.github.com/vroddon/9d5aac253afaa14c9471
âą Open a command line window
âą Test 1
â java -jar TwitterDataCollector.jar
â And you will have searched for tweets containing the word "#eswc2014"
âą Test 2
â java -jar TwitterDataCollector.jar twitterCollector.properties #obama
â And you will have used the given properties file looking for the hashtag
#obama
âą Output: a list of JSONs with Tweet info, one tweet per line
ESWC 2014 Social Web: Where are the Semantics? 7
8. Sample output
âą Hint: use http://jsonviewer.stack.hu/ to see the JSON
ESWC 2014 Social Web: Where are the Semantics? 8