hashtag Archives - Stay N Alive

Developers: Here’s How You Access #Hashtags in Your Apps

I showed earlier tonight a way you can access on Facebook.com the stream for any particular hashtag without having to have a link to get to it. I mentioned Facebook would likely release an API for this. Being the idiot that I am I neglected the fact that Facebook already has a search API, and you can start using it right now.

Anyone, developers or not, can do this right now. Go to https://graph.facebook.com/search – add to it the URI variable q, specify a query (in this case your hashtag keyword prefaced by %23, the URI-encoded version of the # sign), and they add “type=post” to the URI string. In laymans terms, here is how it looks:

https://graph.facebook.com/search?q=%23hashtag&type=post

Just take the above query, put it in your browser (or send it in your app via a GET request), and it will return a JSON-encoded string you can parse and use in your apps. For the non-developers out there, that means there will be a bunch of {‘s and }’s and [‘s and ]’s with the list of all the public posts for that particular hashtag. It’s really simple!

The above example uses the hashtag #hashtag – to change it to something else, just replace “hashtag” with your keyword of choice. This one will do #fail:

https://graph.facebook.com/search?q=%23fail&type=post

Try it yourself and let me know if you see any quirks. So start coding my hacker friends! (and start learning if you’re not!)