Skip to content

Commit

Permalink
Twitter::search() accepts array
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 6, 2011
1 parent 77bb359 commit 961da42
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/search.php
Expand Up @@ -6,6 +6,7 @@
$twitter = new Twitter;

$results = $twitter->search('#nette');
// or use hashmap: $results = $twitter->search(array('q' => '#nette', 'geocode' => '50.088224,15.975611,20km'));

?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Expand Down
8 changes: 6 additions & 2 deletions twitter.class.php
Expand Up @@ -166,14 +166,18 @@ public function destroy($id)

/**
* Returns tweets that match a specified query.
* @param string query
* @param string|array query
* @param int format (JSON | ATOM)
* @return mixed
* @throws TwitterException
*/
public function search($query, $flags = self::JSON)
{
return $this->request('http://search.twitter.com/search.' . self::getFormat($flags), array('q' => $query))->results;
return $this->request(
'http://search.twitter.com/search.' . self::getFormat($flags),
is_array($query) ? $query : array('q' => $query),
'GET'
)->results;
}


Expand Down

0 comments on commit 961da42

Please sign in to comment.