public function TwitterBlockSearch::getJSON in Twitter Block 6
Same name and namespace in other branches
- 7 twitter_block.class.php \TwitterBlockSearch::getJSON()
Retrieve JSON encoded search results
File
- ./
twitter_block.class.php, line 76 - Lightweight implementation of the Twitter API in PHP.
Class
- TwitterBlockSearch
- TwitterBlockSearch provides the class for using the Twitter Search API.
Code
public function getJSON() {
$response = call_user_func(array(
$this,
$this->search_type,
));
$return = array(
'status' => TRUE,
'results' => array(),
'debug' => $response,
);
if (empty($response)) {
$return['status'] = 'Empty response from Twitter.';
}
else {
$decoded = json_decode($response);
if (empty($decoded)) {
$return['status'] = 'Response from Twitter is not valid JSON data.';
}
elseif ($this->api == 'rest') {
$data = $decoded;
}
else {
$data = $decoded->results;
}
// An error from the API.
if (!empty($data->error)) {
$return['status'] = $data->error;
}
else {
$return['results'] = $data;
}
}
return $return;
}