checkRateLimit('search', 'tweets'); // Set the API path $path = '/search/tweets.json'; // Set query parameter. $data['q'] = rawurlencode($query); // Check if callback is specified. if ($callback) { $data['callback'] = $callback; } // Check if geocode is specified. if ($geocode) { $data['geocode'] = $geocode; } // Check if lang is specified. if ($lang) { $data['lang'] = $lang; } // Check if locale is specified. if ($locale) { $data['locale'] = $locale; } // Check if result_type is specified. if ($result_type) { $data['result_type'] = $result_type; } // Check if count is specified. if ($count != 15) { $data['count'] = $count; } // Check if until is specified. if ($until) { $data['until'] = $until; } // Check if since_id is specified. if ($since_id > 0) { $data['since_id'] = $since_id; } // Check if max_id is specified. if ($max_id > 0) { $data['max_id'] = $max_id; } // Check if entities is specified. if (!is_null($entities)) { $data['include_entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'GET', $data); } /** * Method to get the authenticated user's saved search queries. * * @return array The decoded JSON response * * @since 12.3 */ public function getSavedSearches() { // Check the rate limit for remaining hits $this->checkRateLimit('saved_searches', 'list'); // Set the API path $path = '/saved_searches/list.json'; // Send the request. return $this->sendRequest($path); } /** * Method to get the information for the saved search represented by the given id. * * @param integer $id The ID of the saved search. * * @return array The decoded JSON response * * @since 12.3 */ public function getSavedSearchesById($id) { // Check the rate limit for remaining hits $this->checkRateLimit('saved_searches', 'show/:id'); // Set the API path $path = '/saved_searches/show/' . $id . '.json'; // Send the request. return $this->sendRequest($path); } /** * Method to create a new saved search for the authenticated user. * * @param string $query The query of the search the user would like to save. * * @return array The decoded JSON response * * @since 12.3 */ public function createSavedSearch($query) { // Set the API path $path = '/saved_searches/create.json'; // Set POST request data $data['query'] = rawurlencode($query); // Send the request. return $this->sendRequest($path, 'POST', $data); } /** * Method to delete a saved search for the authenticating user. * * @param integer $id The ID of the saved search. * * @return array The decoded JSON response * * @since 12.3 */ public function deleteSavedSearch($id) { // Check the rate limit for remaining hits $this->checkRateLimit('saved_searches', 'destroy/:id'); // Set the API path $path = '/saved_searches/destroy/' . $id . '.json'; // Send the request. return $this->sendRequest($path, 'POST'); } }