Use TwitterVapor to easily send tweets from your vapor server. This is a work in progress and currently only supports sending tweets to one account.
let consumerCredentials = TwitterVaporCredential(key: Environment.get("CONSUMER_KEY")!, secret: Environment.get("CONSUMER_SECRET")!)
let userCredentials = TwitterVaporCredential(key: Environment.get("USER_KEY")!, secret: Environment.get("USER_SECRET")!)
app.twitter.credentials = TwitterVaporCredentials(consumer: consumerCredentials, user: userCredentials)
func postTweet(_ req: Request) throws -> EventLoopFuture<HTTPStatus> {
guard let tweet = req.query[String.self, at: "tweet"] else {
throw Abort(.badRequest)
}
return req.twitter.post(tweet).transform(to: .ok)
}
- OhhAuth - Modified to use SwiftCrypto
- Vapor 4
Currently used for @RivrForiOS