Texting, Tweeting

For a couple of days, I've sat down with the Twitter API and tried to integrate it with the 46elks API for a self-deployable solution to make a demo of how to make it possible for me to send SMS to Twitter[1]. The result is the Flask based microservice Passer .

DIY Install Passer on Heroku

Passer still contains quite a bit of rough edges[2] but deployment to Heroku is as simple as A-B-C[3]. You can clone Passer from github.com/46elks/passer and add it to your Heroku apps by executing the Heroku toolchain command heroku create within the repository.

After you've launched the Heroku instance, you'll need to configure a few environment variables for your application. First, head over to apps.twitter.com and create a new app. Within the app, access your consumer key and consumer secret and store them within your Heroku instance's environment variables using

heroku config:set PASSER_TWITTER_KEY=<consumer_key>\
PASSER_TWITTER_SECRET=<consumer_secret>

Next head to the 46elks dashboard where you'll configure a number[4] to have the sms_url https://<yourapp>.herokuapps.com/incoming_sms . While you're at the 46elks dashboard, also retrieve your API username and password and insert them into the environment variables with

heroku config:set PASSER_ELKS_KEY=<api_username>\
PASSER_ELKS_SECRET=<api_password>

Now it's just a matter of running git push heroku and voilá, you're up and running. Go to https://<yourapp>.herokuapps.com/authorize and follow the link to Twitter where you'll authorize the app and copy the digits Twitter instructs you to enter into Passer by running https://<yourapp>.herokuapps.com/authorize/<digits> .

Congratulations, you should now be able to send a text message to the number you configured and it'll magically appear on your Twitter wall.

What's next?

Wow, Passer is really not done. It's not even nearly done. I'd love to actually make this tech demo useful by allowing for persistent OAuth tokens one way or another, but also allowing for you to upload pictures and gifs through MMS. Maybe make it possible for you to get the replies to tweets you've made using Passer?

Have you got any good idea for Passer, feel free to contact me on Twitter, @sakjur or open a pull request/issue at github.com/46elks/passer .

Footnotes

[1] Twitter do provide Twitter over SMS but it's not available for customers in a lot of countries
[2] Passer doesn't persistently store OAuth tokens, so you'll have to re-authenticate on every restart of the application
[3] You can of course deploy Passer to your own server as well using for example uWSGI, but this is sadly not nearly as straight forward
[4] SE-numbers are €1 a month, but we have this amazing trial-thingy, so you can try Passer without having to spend a krona :D

Written 2015-09-18 12:00 by Emil Tullstedt