/** * The final step of the OAuth workflow. After this the client can make * API calls. * * @param string $verifier Verifier given to user or passed to your callback. * * @return array */ public function getAccessToken($verifier = '') { $uri = $this->oauth_base_url . '/oauth/access_token/'; $data = array('oauth_version' => '1.0', 'oauth_nonce' => $this->_genNonce(), 'oauth_timestamp' => time(), 'oauth_verifier' => $verifier, 'oauth_signature_method' => 'PLAINTEXT', 'oauth_consumer_key' => $this->_client_token, 'oauth_token' => $this->_request_token, 'oauth_signature' => $this->_client_secret . '%26' . $this->_request_secret); $result = parent::doRequest($uri, 'post', $data); $result = $this->getBody($result); //convert returned string to array for easy access parse_str($result, $result); $this->_access_token = $result['oauth_token']; $this->_access_secret = $result['oauth_token_secret']; return $result; }
/** * Override the parent class to add Basic Authentication here. * Actually makes the HTTP request * * @param string $uri Url of the Request * @param string $method Http Method * @param array $data Http Parameters * @param string $extra_headers Extra Headers Such as Authentication Information * * @return array */ public function doRequest($uri, $method, $data = null, $extra_headers = array()) { $auth = base64_encode($this->_api_key . ":" . $this->_api_pwd); $extra_headers["Authorization"] = "Basic " . $auth; return parent::doRequest($uri, $method, $data, $extra_headers); }