score:4
I have found this to work:
WS.url("http://api.twitter.com/1/users/lookup.json?user_id="+listOfFollowers)
.sign(OAuthCalculator(Twitter.KEY, tokens))
.post("ignored")
.map { response =>
val screenName: Seq[String] = response.json match {
case res: JsArray => res.value.map{ 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.
score:1
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()
.setOAuthConsumerKey(twitterKey)
.setOAuthConsumerSecret(twitterSecret)
.setOAuthAccessToken(token)
.setOAuthAccessTokenSecret(secret)
.build()
val twitter = new TwitterFactory(config).getInstance()
val status = new StatusUpdate(tweet)
status.media(photoName, 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.
Source: stackoverflow.com
Related Query
- Sending POST Request to Twitter API with Play Framework 2.0
- How handle a POST request with Kafka, Alpakka Kafka, Play Framework and Websocket?
- Send POST request with parameters in body via Play WS API
- Play Framework sending POST request data to GET
- Send POST request with a body using scala and play framework
- How to http post with an empty body request using WS API in Playframework 2 / Scala?
- Testing request with CSRF Token in Play framework 2.5 (Scala)
- Play Framework & Scala: Problems with FakeRequest & JSON POST in unit test
- play framework 2: test a request with a json string as body
- How to read and write Anorm object with the new JSON API in Play Framework 2.1-RC2?
- Play Framework Form validation messages with Twitter Bootstrap fields
- Binding form request with ManyToOne field on play framework 2
- Play Framework request attributes with typed key
- Scala - parse JSON data from API with ScalaJson Play Framework
- Play Framework: POST request with parameters
- How to redirect request in play framework with scala?
- Scala Play framework POST request using request body
- Play Framework Ning WS API encoding issue with HTML pages
- Display Form Validation error messages with twitter bootstrap in scala and Play framework
- How to make internal synchronous post request in Play framework and scala?
- Parse request body with custom content-type to json in Play Framework
- JsError while trying to parse JSON file into case class with Play framework API in Scala
- Scala Play framework rest api add token from request to response
- Scala with Play Framework 2.3.6: sending a message to all socket clients
- It seems that it is not possible to do POST with body >10K with scala play ws framework
- Play Framework 2.2 - Error when creating Form of model class with name Request
- How to send POST data with an AngularJS form to Play Framework Controller
- Oauth 1.0 with Play framework - get instead of post
- Securing REST API on Play framework and OAuth2
- How to use IntelliJ with Play Framework and Scala
More Query from same tag
- Recursive DataType in Scala
- Scala: getting error as "Expression of type Unit doesn't confirm to expected type..."
- Spark distinct performance issue after joining
- Update label on button hit, before calling function
- What's the suggest way to shutdown akka remote client
- Setting unique snapshot version when cross-building in SBT
- is it possible (and how) to specify an sql query on command line with spark-submit
- Lift full types into monad transformers
- In Scala, can I (would some SIP allow me to) specify only certain type parameters of a generic method?
- json4s, how to deserialize json with FullTypeHints w/o explicitly setting TypeHints
- Java optional: map to subclass or else super class
- Code coverage on Play! project
- Using Circe to decode Json String
- Weird type inference in scala
- Howto read Excel file in Scala
- How can I run a package created with Simple Build Tool?
- Error handling in for comprehension
- How to launch a Jar file using Spark on hadoop
- How to get inserted object back (with default values from database)?
- Scala REPL crashes when started using scala.tools.nsc.interpreter
- build.sbt - iteration over sub projects for common settings in monorepo
- Unable to create cinnamon metrics with akka.actor.ActorContext but when I use akka.actor.ActorSystem, then cinnamon metrics works fine
- IntelliJ with SBT plugin: Error Resolving [com.mycompany.mypackage]
- Spark scala join each group in data frame with other reference data frame
- Trying to deserialize a serialized ActorRef without an ActorSystem in scope - Spark/Akka/Scala
- Is it possible to create a Flow with Akka-stream that can switch between 2 different inner Shapes?
- Spark-Monotonically increasing id not working as expected in dataframe?
- How do add values of selective rows from a list in an functional style?
- Row with schema returns null for row.schema
- Slick: How to filter by isBefore Timestamp database attribute?