Entries tagged with “Brightkite”
- All (4)
- Entries (2)
- Links (2)
- Photos (0)
Posting to Brightkite using ActiveResource and REST
The other day, I came across Brightkite’s REST API. After taking a look at it, I decided it was the perfect opportunity to try out ActiveResource, the dead simple way to consume RESTful resources. In 20 lines, I was able to put together a simple script to find your most recent check-in on Brightkite and then post to that place.
A Quick Intro To Active Resource
First off, here’s an idea of just how easy it is to connect to a REST API using ActiveResource. Take, for instance, the “places” resource in Brightkite; these URLs all have the base http://brightkite.com/places. To interface with places, all it takes is this:
class Place < ActiveResource::Base
self.site = 'http://brightkite.com'
end
That’s it. To get all the places, just do Place.find(:all). To create a new place, all it takes is Place.new. Amazing, to say the least. There’s a lot more that’s possible, so I recommend you check out the ActiveResource page on the Rails wiki.
The code
Below are the 20 lines necessary to post a note to Brightkite through the API. Just change USERNAME and PASSWORD to your username and password and change the note text at the bottom, and you’re ready to go. While this is a pretty simple example, it shows just how powerful a well constructed REST API can be.
Getting Brightkite and Verizon to Play Nicely
After hearing all about Brightkite from Brandice and Colin, I decided to take the plunge and try out the service a few weeks ago. In the time since, I’ve become addicted to the service, and I’m constantly amazed at how well thought out the site is. One thing that really bugged me, though, is that Brightkite doesn’t work with Verizon text messages. After being initially disheartened, I found getting around the issue to be pretty easy: instead of text messages, I used PIX messages.
If you take a look at Brightkite’s SMS Guide when logged into the service, you’ll notice a email under “Post a photo to a place.” This is the email you’ll be sending your updates to. To use any of the mobile commands (PDF) with Verizon, just send a PIX message to the email address without a photo attached. Put your command in the “text” field, send the message, and you should be good to go.
A word of caution: if you don’t have unlimited picture messaging, this method may end up being very costly. I’m not sure if Verizon still charges their PIX rate for messages without pictures, but if they do, make sure you’re not going over your allotted number of messages.
Hopefully, Verizon will fix whatever issue is breaking the Brightkite integration soon, so we don’t have to continue to hack around the problem. In the meantime, however, this method should continue to work; I haven’t had any issues with it thus far.
