Simple Twitter Search with PHP
So, I've already gone into detail on the Arc90 Twitter API Service and it's pretty fun to work with. One small problem though; it's pretty big, complicated and, well, bulky. There's a lot you have to do to get something up and running.
Enter PHPTwitterSearch; a pretty easy to use, lightweight, Twitter API Search class. It's based on the class originally developed by David Billingham, which I admit, I didn't check out so I don't know how much it's based on.
The thing I didn't really like about the Arc90 script was how complicated the search process was. In case you didn't notice, I didn't go into any detail about the search process; for precisely because it was just to complicated. I stopped having fun when working with the search functionality.
Simplicity was what immediately drew me to PHPTwitterSearch. Here's a basic example of a search:
1 2 3 4 5 6
<?php $query = 'findme'; $search = new SWTwitterSearch(); $search = new TwitterSearch($query); $results = $search->results(); ?>
Very, very simple. The above searches the API for $query.
Here's the best part though; for a little more complication all you have to do is chain the calls together.
1 2 3 4 5
<?php $search = new SWTwitterSearch(); $search = new TwitterSearch(); $results = $search->from('username')->with('hashtag')->to('username2')->results(); ?>
The above searches the API for tweets from "username" with the hash string "#hashtag" that was sent to the user "username2".
The class returns an array with objects that's really basic and simple.