Using JSON to access the Twitter search API

Bookmark and Share

Steve Reynolds recently wrote a blog post showing how to access the twitter search API using PHP, cURL, and JQuery.

Steve used JQuery to post to a page on his server, which then cURLed in search results for a given term. This approach is often necessary to get avoid the issue of cross domain ajax calls.

While this approach works well, there’s an even easier way to go about it – $.getJSON!

There are two main advantages to this approach:

  • Server side technology isn’t an issue. You don’t have to rely on PHP, cURL, firewalls, anything like that. It will even work on a static HTML page!
  • All the work is done on the client’s browser – saving precious bandwidth! This could be important on busy sites.

I’ve knocked up a quick-and-dirty demonstration of this concept. If a name doesn’t already exist for this methodology, my vote goes for JAJA (Javascript and JSON, asynchronous!)

View the demonstration here!

Tags: , ,

This entry was posted on Saturday, February 7th, 2009 at 9:35 am and is filed under AJAX, jquery, web development. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

 

10 Responses to “Using JSON to access the Twitter search API”

  1. Steve ReynoldsNo Gravatar Says:

    Thanks for this! Can you do authenticated calls to the Twitter API using this?

  2. adminNo Gravatar Says:

    @Steve Reynolds – you can’t. The twitter search API is different from the main Twitter API, which requires authentication. PHP + cURL would be the way to go for that. :)

  3. MatthewNo Gravatar Says:

    Thanks, i was going to ask the same question as steve, thanks for the answer, and nice post, this still has some really cool applications.

  4. DavidNo Gravatar Says:

    I thought that you couldn’t harvest cross-site with JS?
    I like the name of JAJA :)
    That example is not working in my browser. FF3.02 on Linux.

  5. Web Design GlasgowNo Gravatar Says:

    Great concept, but I also had a problem of no response in the demo.
    regards
    George

  6. Twitter SearchNo Gravatar Says:

    thats great that you are talking about the twitter api,a good example of searching with the twitter api is on twiogle.com because you can search on twitter and google at the same time.

  7. IanNo Gravatar Says:

    Great followup to Steve Reynolds’ article using the JSON aproach. Interesting to see how the two compare. However your demo doesn’t seem to be working. I’d love to see it in action. Can this be fixed?

  8. online adverterenNo Gravatar Says:

    Too bad JSON doesn’t work with IE8 yet. Perhaps I will help the developper and post some bugreports.

    - Mike

  9. kapstanNo Gravatar Says:

    Wha’s the best brower for this?

  10. Alistair ConditioningNo Gravatar Says:

    very interesting, although i still had problems with the demo