O'Reilly logo

PHP Ajax Cookbook by R. Rajesh Jeba Anbiah, Roshan Bhattarai, Milan Sedliak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Twitter API with Ajax

In this section, we will see how to create a tool using PHP and Ajax that uses Twitter search API to retrieve the tweets from the user containing the searched for keyword. We will use Ajax, PHP, and Twitter API to make this tool.

Getting ready

You can call the Twitter search API as follows:

http://search.twitter.com/search.format?q=your_query_string

In the previous call, the format can be replaced with json or atom. Furthermore, we can make a JSONP call with the extra callback parameter.

http://search.twitter.com/search.format?q=your_query_string&callback=?

Let's suppose we want to search tweets with php in the search keyword and have the response in JSON format; then we can call the Twitter API like this:

http://search.twitter.com/search.json?q=php ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required