Notes from a small website

A week ago, I tweeted:

After a long weekend of coding, I’ve got a brand new section on my website.

http://adactio.com/notes/

But that tweet did not originate on Twitter. That tweet is a copy. The original is here.

To be honest, I’ve never been that pushed about having my own bite-sized updates hosted on my own site and syndicated out to Twitter. I’m much more concerned about my photos. Still, I thought it was pretty cool the way that Chloe, Aaron, Amber, and Barnaby have a “notes” section on their sites hosting the canonical URLs of their updates, so I thought I’d give it a shot too.

Michael Bester has written about his online homesteading process. You can also read—or listen toChloe’s process.

Creating a new section on my own site is pretty straightforward. My home-rolled CMS is really creaky and ropey but it gets the job done. The notes section is just another kind of post, same as journal, links, and articles. The tricky bit (for me) was figuring out how to post a copy to Twitter.

It was pretty clear which API method I needed to use. The hard part was all the OAuth stuff. I’ve never meddled with that kind of voodoo before.

I signed into dev.twitter.com and created an application called adactio.com. I’m given an API key and an API secret. This application will only never need to post as me, so I was able to take advantage of single-user OAuth to generate my access token and access token secret:

By using a single access token, you don’t need to implement the entire OAuth token acquisition dance.

Now I had the four pieces I needed to send with a status update:

  1. my consumer key,
  2. my consumer secret,
  3. my access token, and
  4. my access token secret.

I found a small PHP library that uses Andy’s OAuth code. Looking at the source code, I was able to figure out what I needed to send to Twitter. The OAuth class is doing all the hard work—my PHP code is fairly basic.

Imagine my surprise when it actually worked.

I fiddled around with my site’s crude templating system so that if I’m logged into my little CMS, I’m presented with a simple update form on the front page of adactio.com.

Speak your brains on Dribbble

When I type a note into that form and hit “post”, here’s what happens:

  1. I store the note in my own database.
  2. I send a copy to Twitter as a status update.
  3. Twitter returns a JSON object with info about the tweet I just created.
  4. I take the ID of that tweet and store it in my database along with the original note.

Having the ID of the copy on Twitter allows me to provide some Twitter-specific actions from my own site: reply, retweet, fave, etc.

Note on Dribbble

Okay, so now I’m posting to Twitter from my own site. Nifty! But what about receiving notifications from Twitter? If someone replies to, or likes, or favourites the copy of my note on Twitter, it would be nice to get notified about it on adactio.com.

This would be a really complex problem to attempt to solve for myself, but fortunately I don’t have to. Brid.gy is a magical tool written by Ryan Barrett that you can authorise to watch your Twitter profile. It will send a webmention back to the canonical URL on your own site whenever anyone replies to, or retweets or favourites a post.

Because I’ve already got webmentions on my site, Brid.gy worked straight out of the gate—a lovely demonstration of some small pieces, loosely joined.

Responses on Dribbble

Like I said, I wasn’t all that pushed about hosting my own short updates but now that I’m doing it, I’m really, really enjoying it. It feels good.

It feels good to be using my own website for “microblogging”. I know that’s a distasteful phrase but it’s a fairly accurate way of describing how I tend to use Twitter. My earliest tweets definitely feel like short blog posts.

Conversely, looking back on how I was blogging very early on, a lot of those short posts feel like tweets. So it feels good to bring those notes back to adactio.com.

Have you published a response to this? :

Responses

Josh Russell

oh, unless that is supposed to link to /notes then it’s fine.. just me being confused

adamsimpson.net

Manton Reece recently shared his microblogging setup with WordPress. I have a similar system that was inspired by Jeremy Keith’s example. Like Manton, I had to figure out the quickest way to create a new post. I eventually settled on SMS-to-post thanks (once again) to Twilio. SMS-to-post lets me text my Twilio number which sends the text to WordPress where it becomes a new “note”. Publishing that “note” to Twitter is just a matter of hooking into the WordPress publish_post action and sending the post to Twitter via its API.

Here are a few other implementation notes:

  • I created a custom post type in WordPress called “Notes”.
  • The the post status API makes this entire process smooth.
  • SMS-to-post has a few gotchas, the biggest one is that SMS with emoji are limited to 70 characters.
  • I don’t have an RSS feed for my Notes…yet
  • I save the tweet ID of every post that gets posted to Twitter. I use that ID to pull in the favorite and retweet counts and display them next to each “note” in the WordPress dashboard.
  • Twilio needs an endpoint to POST incoming texts to WordPress. Creating custom endpoints is trivial thanks to this great guide. I also recommend the rewrite rules inspector plugin for working with rewrite rules.

# Thursday, June 25th, 2015 at 10:14am

Tom Coates

@adactio That link’s not working. Probably my internet, unless your site has gone down or something…

# Posted by Tom Coates on Wednesday, July 8th, 2015 at 11:19pm

Tom Coates

@adactio I feel the same way about people using Less instead of Fewer. Everyone tells me to shut up when I go on about it, though.

# Posted by Tom Coates on Wednesday, July 8th, 2015 at 11:23pm

4 Favourites

# Favourited by Tantek Çelik on Monday, June 2nd, 2014 at 1:40am

# Favourited by Kyle Mahan on Monday, June 2nd, 2014 at 1:41am

# Favourited by mirthe on Monday, June 2nd, 2014 at 3:15pm

# Favourited by 爆撃機伍號 on Monday, June 23rd, 2014 at 11:20am

1 Like

# Monday, June 2nd, 2014 at 2:41pm