Accepted answer

I have found this to work:

  .sign(OAuthCalculator(Twitter.KEY, tokens))
  .map { response => 
      val screenName: Seq[String] = response.json match {
          case res: JsArray =>{ value => (value \ "name").toString }
          case _ => Seq("")

I've also made notes to revisit my code with every major upgrade of Play! to check if the above gets fixed, because this is obviously not right.


Once you use the Play Framework tools for getting your user's token and secret, you can then use the twitter4j ("org.twitter4j" % "twitter4j-core" % "3.0.3") library to do your posting like this.

import twitter4j.conf.ConfigurationBuilder
import twitter4j.{StatusUpdate, TwitterFactory}

val config = new ConfigurationBuilder()
val twitter = new TwitterFactory(config).getInstance()
val status = new StatusUpdate(tweet), stream)
val twitResp = twitter.updateStatus(status)

Annoying to have to use two libraries, and twitter4j isn't async so it's slightly less resource-efficient, but it lets you do real posts which are necessary sometimes.

Related Query

More Query from same tag