function TwitterOAuth::http in Tweet Feed 7.3
Same name and namespace in other branches
- 6 inc/twitter-oauth.inc \TwitterOAuth::http()
- 7 inc/twitter-oauth.inc \TwitterOAuth::http()
- 7.2 inc/twitter-oauth.inc \TwitterOAuth::http()
Make an HTTP request
Return value
API results
1 call to TwitterOAuth::http()
- TwitterOAuth::oAuthRequest in inc/
twitter-oauth.inc - Format and sign an OAuth / API request
File
- inc/
twitter-oauth.inc, line 192
Class
- TwitterOAuth
- Twitter OAuth class
Code
function http($url, $method, $postfields = NULL) {
$this->http_info = array();
$ci = curl_init();
/* Curl settings */
curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_HTTPHEADER, array(
'Expect:',
));
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
curl_setopt($ci, CURLOPT_HEADERFUNCTION, array(
$this,
'getHeader',
));
curl_setopt($ci, CURLOPT_HEADER, TRUE);
switch ($method) {
case 'POST':
curl_setopt($ci, CURLOPT_POST, TRUE);
if (!empty($postfields)) {
curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
}
break;
case 'DELETE':
curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
if (!empty($postfields)) {
$url = "{$url}?{$postfields}";
}
}
curl_setopt($ci, CURLOPT_URL, $url);
$response = curl_exec($ci);
// Get the response headers and parse them out. Then adjust the body accordingly
$header_size = curl_getinfo($ci, CURLINFO_HEADER_SIZE);
$body = substr($response, $header_size);
$this->http_headers = $this
->get_headers_from_curl_response($response);
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
$this->url = $url;
curl_close($ci);
return $body;
}