You are here

public function TwitterBlockSearch::__construct in Twitter Block 7

Same name and namespace in other branches
  1. 6 twitter_block.class.php \TwitterBlockSearch::__construct()

File

./twitter_block.class.php, line 42
Lightweight implementation of the Twitter API in PHP.

Class

TwitterBlockSearch
TwitterBlockSearch provides the class for using the Twitter Search API.

Code

public function __construct($config = array()) {

  // @todo: Make this a configurable URL.
  $this->url_query = 'http://search.twitter.com/search.json?';
  $this->search_type = $config['search_type'];
  $this->api = in_array($this->search_type, array(
    'getTweetsFrom',
  )) ? 'rest' : 'search';
  if ($config['search_type'] == 'searchHashtag') {

    // We presume the search string is already validated.
    $this->search_string = $config['search_string'];
  }
  else {
    $this->twitter_name = $config['search_string'];
  }
  $this->include_rts = $config['include_rts'];
  $count = $this->api == 'rest' ? 'count' : 'rpp';

  // The number of tweets to return per page.
  $this->options[$count] = $config['results_per_page'];

  // Filter by language, but only if there is one set in the config.
  if (isset($config['lang']) && !empty($config['lang'])) {
    $this->options['lang'] = $config['lang'];
  }
}