protected function Twitter::request in Twitter 6.5
Same name and namespace in other branches
- 6.3 twitter.lib.php \Twitter::request()
- 7.6 twitter.lib.php \Twitter::request()
- 7.3 twitter.lib.php \Twitter::request()
- 7.5 twitter.lib.php \Twitter::request()
Performs a request.
Throws
1 call to Twitter::request()
- Twitter::auth_request in ./
twitter.lib.php - Performs an authenticated request.
File
- ./
twitter.lib.php, line 133 - Integration layer to communicate with the Twitter REST API 1.1. https://dev.twitter.com/docs/api/1.1
Class
- Primary Twitter API implementation class
Code
protected function request($url, $params = array(), $method = 'GET') {
$data = '';
if (count($params) > 0) {
if ($method == 'GET') {
$url .= '?' . http_build_query($params, '', '&');
}
else {
$data = http_build_query($params, '', '&');
}
}
$headers = array();
$headers['Authorization'] = 'Oauth';
$headers['Content-type'] = 'application/x-www-form-urlencoded';
$response = $this
->doRequest($url, $headers, $method, $data);
if (!isset($response->error)) {
return $response->data;
}
else {
$error = $response->error;
$data = $this
->parse_response($response->data);
if (isset($data['error'])) {
$error = $data['error'];
}
throw new TwitterException($error);
}
}