protected function doOAuthCall($method, array $parameters = null)
{
// redefine
$method = (string) $method;
// append default parameters
$parameters['oauth_consumer_key'] = $this->getConsumerKey();
$parameters['oauth_nonce'] = md5(microtime() . rand());
$parameters['oauth_timestamp'] = time();
$parameters['oauth_signature_method'] = 'HMAC-SHA1';
$parameters['oauth_version'] = '1.0';
// calculate the base string
$base = $this->calculateBaseString(self::SECURE_API_URL . '/oauth/' . $method, 'POST', $parameters);
// add sign into the parameters
$parameters['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() . '&' . $this->getOAuthTokenSecret(), $base);
// calculate header
$header = $this->calculateHeader($parameters, self::SECURE_API_URL . '/oauth/' . $method);
// set options
$options[CURLOPT_URL] = self::SECURE_API_URL . '/oauth/' . $method;
$options[CURLOPT_PORT] = self::SECURE_API_PORT;
$options[CURLOPT_USERAGENT] = $this->getUserAgent();
if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) {
$options[CURLOPT_FOLLOWLOCATION] = true;
}
$options[CURLOPT_RETURNTRANSFER] = true;
$options[CURLOPT_TIMEOUT] = (int) $this->getTimeOut();
$options[CURLOPT_SSL_VERIFYPEER] = false;
$options[CURLOPT_SSL_VERIFYHOST] = false;
$options[CURLOPT_HTTPHEADER] = array('Expect:');
$options[CURLOPT_POST] = true;
$options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
// init
$this->curl = curl_init();
// set options
curl_setopt_array($this->curl, $options);
// execute
$response = curl_exec($this->curl);
$headers = curl_getinfo($this->curl);
// fetch errors
$errorNumber = curl_errno($this->curl);
$errorMessage = curl_error($this->curl);
// error?
if ($errorNumber != '') {
throw new Exception($errorMessage, $errorNumber);
}
// init var
$return = array();
// parse the string
parse_str($response, $return);
// return
return $return;
}