You are here

public function TwitterBlockSearch::__construct in Twitter Block 6

Same name and namespace in other branches
  1. 7 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.
  if (!empty($config['results_per_page'])) {
    $this->options[$count] = $config['results_per_page'];
  }
  else {
    $this->options[$count] = variable_get('twitter_block_default_results_per_page', 15);
  }

  // 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'];
  }
}