Skip to content

DanielaSfregola/twitter4s-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twitter4s-demo

Build Status License Chat

Examples on how to use twitter4s library.

Usage

Make sure to set up your consumer and access tokens -- see twitter4s README - Usage Section for more information.

Run the examples with sbt run and choose the main to run.

TwitterRestClient Examples

  • MyTopHashtags displays the top 10 most common hashtags in the home timeline (i.e.: the timeline of the authenticated user).
  • SearchAndSaveTweets searches all the tweets matching some query and it saves the result as JSON in a file. In this example, the query used is #scalax and the generated file is src/main/resources/tweets/scalax.json.
  • SimpleStatistics loads tweets from a file, in this case src/main/resources/tweets/scalax.json, and it computes some simple statistics: top hashtags, top active users, top mentioned users, top retweets, top favorite tweets.
  • UserTopHashtags displays the top 10 most common hashtags in a user timeline. In this example, we use Martin Odersky's account.
  • TrendingTopics displays the top 10 trending topics worldwide, and in a given location (by text and by geolocation).
  • LastTweetInTimeline displays the last tweet in your timeline.
  • FollowersRegisteredTheSameYear display for a user, the followers registered the same year.
  • ShowTermsOfService display Twitter's terms of service.
  • ShowPrivacyPolicy display Twitter's Privacy Policy.

TwitterStreamingClient Examples

Troubleshooting

If you have this exception javax.net.ssl.SSLHandshakeException: General SSLEngine problem add the certificate of the twitter api to jre truststore.

echo -n | \
openssl s_client -connect api.twitter.com:443 </dev/null | \
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/twitter-api.crt && \
sudo keytool -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -noprompt -alias twitterapi -file /tmp/twitter-api.crt

if the alias already exists, delete it before.

sudo keytool -delete -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -alias twitterapi

Bugs

Spotted some bugs? Please, raise them in the twitter4s issue section.

About

A collection of examples on how to use twitter4s

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages