private function request($url, $params = false, $type = "GET") { Hybrid_Logger::info("Enter OAuth2Client::request( {$url} )"); Hybrid_Logger::debug("OAuth2Client::request(). dump request params: ", serialize($params)); if ($type == "GET") { $url = $url . (strpos($url, '?') ? '&' : '?') . http_build_query($params, '', '&'); } $this->http_info = array(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $this->api->curl_time_out); curl_setopt($ch, CURLOPT_USERAGENT, $this->api->curl_useragent); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->api->curl_connect_time_out); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->api->curl_ssl_verifypeer); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->api->curl_header); if ($this->api->curl_proxy) { curl_setopt($ch, CURLOPT_PROXY, $this->api->curl_proxy); } if ($type == "POST") { curl_setopt($ch, CURLOPT_POST, 1); if ($params) { curl_setopt($ch, CURLOPT_POSTFIELDS, $params); } } $response = curl_exec($ch); Hybrid_Logger::debug("OAuth2Client::request(). dump request info: ", serialize(curl_getinfo($ch))); Hybrid_Logger::debug("OAuth2Client::request(). dump request result: ", serialize($response)); $this->http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $this->http_info = array_merge($this->http_info, curl_getinfo($ch)); curl_close($ch); return $response; }
/** * clear the last error */ public static function clearError() { Hybrid_Logger::info("Enter Hybrid_Error::clearError()"); Hybrid_Auth::storage()->delete("hauth_session.error.status"); Hybrid_Auth::storage()->delete("hauth_session.error.message"); Hybrid_Auth::storage()->delete("hauth_session.error.code"); Hybrid_Auth::storage()->delete("hauth_session.error.trace"); Hybrid_Auth::storage()->delete("hauth_session.error.previous"); }
private function request($url, $params = false, $type = "GET") { $params = http_build_query($params, '', '&'); Hybrid_Logger::info("Enter OAuth2Client::request( {$url} )"); Hybrid_Logger::debug("OAuth2Client::request(). dump request params: ", $params); if ($type == "GET") { $url = $url . (strpos($url, '?') ? '&' : '?') . $params; } $this->http_info = array(); $ch = curl_init(); $headers = $this->curl_header; if ($type == "POST") { //$headers[] = 'Content-Type: application/x-www-form-urlencoded'; } curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_time_out); curl_setopt($ch, CURLOPT_USERAGENT, $this->curl_useragent); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->curl_connect_time_out); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->curl_ssl_verifypeer); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->curl_ssl_verifyhost); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_USERPWD, $this->client_id . ':' . $this->client_secret); // logging if ($this->curl_log !== null) { $fp = fopen($this->curl_log, 'a'); curl_setopt($ch, CURLOPT_STDERR, $fp); curl_setopt($ch, CURLOPT_VERBOSE, 1); } if ($this->curl_proxy) { curl_setopt($ch, CURLOPT_PROXY, $this->curl_proxy); } if ($type == "POST") { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); } $response = curl_exec($ch); if ($this->curl_log !== null) { fclose($fp); } if ($response === FALSE) { Hybrid_Logger::error("OAuth2Client::request(). curl_exec error: ", curl_error($ch)); } Hybrid_Logger::debug("OAuth2Client::request(). dump request info: ", serialize(curl_getinfo($ch))); Hybrid_Logger::debug("OAuth2Client::request(). dump request result: ", serialize($response)); $this->http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $this->http_info = array_merge($this->http_info, curl_getinfo($ch)); curl_close($ch); return $response; }
/** * define:endpoint step 3.1 and 3.2 */ public static function processAuthDone() { Hybrid_Endpoint::authInit(); $provider_id = trim(strip_tags(Hybrid_Endpoint::$request["hauth_done"])); $hauth = Hybrid_Auth::setup($provider_id); if (!$hauth) { Hybrid_Logger::error("Endpoint: Invalide parameter on hauth_done!"); $hauth->adapter->setUserUnconnected(); header("HTTP/1.0 404 Not Found"); die("Invalide parameter! Please return to the login page and try again."); } try { Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() "); $hauth->adapter->loginFinish(); } catch (Exception $e) { Hybrid_Logger::error("Exception:" . $e->getMessage(), $e); Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e); $hauth->adapter->setUserUnconnected(); } Hybrid_Logger::info("Endpoint: job done. retrun to callback url."); $hauth->returnToCallbackUrl(); die; }
// with /index.php?hauth.done={provider}?{args}... if (strrpos($_SERVER["QUERY_STRING"], '?')) { $_SERVER["QUERY_STRING"] = str_replace("?", "&", $_SERVER["QUERY_STRING"]); parse_str($_SERVER["QUERY_STRING"], $_REQUEST); } $provider_id = trim(strip_tags($_REQUEST["hauth_done"])); $hauth = Hybrid_Auth::setup($provider_id); if (!$hauth) { Hybrid_Logger::error("Endpoint: Invalide parameter on hauth_done!"); $hauth->adapter->setUserUnconnected(); header("HTTP/1.0 404 Not Found"); die("Invalide parameter! Please return to the login page and try again."); } try { Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() "); $hauth->adapter->loginFinish(); } catch (Exception $e) { Hybrid_Logger::error("Exception:" . $e->getMessage(), $e); Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e); $hauth->adapter->setUserUnconnected(); } Hybrid_Logger::info("Endpoint: job done. retrun to callback url."); $hauth->returnToCallbackUrl(); die; } } else { # Else, # We advertise our XRDS document, something supposed to be done from the Realm URL page echo str_replace("{X_XRDS_LOCATION}", Hybrid_Auth::getCurrentUrl(false) . "?get=openid_xrds&v=" . Hybrid_Auth::$version, file_get_contents(dirname(__FILE__) . "/Hybrid/resources/openid_realm.html")); die; }
/** * set user to unconnected */ public function setUserUnconnected() { Hybrid_Logger::info("Enter [{$this->providerId}]::setUserUnconnected()"); Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.is_logged_in", 0); }
/** * Utility function, redirect to a given URL with php header or using javascript location.href * * @param string $url URL to redirect to * @param string $mode PHP|JS */ public static function redirect($url, $mode = "PHP") { Hybrid_Logger::info("Enter Hybrid_Auth::redirect( {$url}, {$mode} )"); // Ensure session is saved before sending response, see https://github.com/symfony/symfony/pull/12341 if (PHP_VERSION_ID >= 50400 && PHP_SESSION_ACTIVE === session_status() || PHP_VERSION_ID < 50400 && isset($_SESSION) && session_id()) { session_write_close(); } if ($mode == "PHP") { header("Location: {$url}"); } elseif ($mode == "JS") { echo '<html>'; echo '<head>'; echo '<script type="text/javascript">'; echo 'function redirect(){ window.top.location.href="' . $url . '"; }'; echo '</script>'; echo '</head>'; echo '<body onload="redirect()">'; echo 'Redirecting, please wait...'; echo '</body>'; echo '</html>'; } die; }
/** * Make http request */ function request($url, $method, $postfields = NULL, $auth_header = NULL, $content_type = NULL) { Hybrid_Logger::info("Enter OAuth1Client::request( {$method}, {$url} )"); Hybrid_Logger::debug("OAuth1Client::request(). dump post fields: ", serialize($postfields)); $this->http_info = array(); $ci = curl_init(); /* Curl settings */ curl_setopt($ci, CURLOPT_USERAGENT, $this->curl_useragent); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->curl_connect_time_out); curl_setopt($ci, CURLOPT_TIMEOUT, $this->curl_time_out); curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->curl_ssl_verifypeer); curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader')); curl_setopt($ci, CURLOPT_HEADER, FALSE); if ($content_type) { curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:', "Content-Type: {$content_type}")); } if ($this->curl_proxy) { curl_setopt($ci, CURLOPT_PROXY, $this->curl_proxy); } switch ($method) { case 'POST': curl_setopt($ci, CURLOPT_POST, TRUE); if (!empty($postfields)) { curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } if (!empty($auth_header) && $this->curl_auth_header) { curl_setopt($ci, CURLOPT_HTTPHEADER, array('Content-Type: application/atom+xml', $auth_header)); } 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); if ($response === FALSE) { Hybrid_Logger::error("OAuth1Client::request(). curl_exec error: ", curl_error($ci)); } Hybrid_Logger::debug("OAuth1Client::request(). dump request info: ", serialize(curl_getinfo($ci))); Hybrid_Logger::debug("OAuth1Client::request(). dump request result: ", serialize($response)); $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE); $this->http_info = array_merge($this->http_info, curl_getinfo($ci)); curl_close($ci); return $response; }
private function request($url, $params = false, $type = "GET") { Hybrid_Logger::info("Enter OAuth2Client::request( {$url} )"); Hybrid_Logger::debug("OAuth2Client::request(). dump request params: ", serialize($params)); if ($type == "GET") { $url = $url . (strpos($url, '?') ? '&' : '?') . http_build_query($params); } $this->http_info = array(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_time_out); curl_setopt($ch, CURLOPT_USERAGENT, $this->curl_useragent); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->curl_connect_time_out); $config = Yii::app()->getModule('hybridauth')->getConfig(); if ($config['proxy']) { curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTPS'); curl_setopt($ch, CURLOPT_PROXY, $config['proxy']['url']); curl_setopt($ch, CURLOPT_PROXYPORT, $config['proxy']['port']); if ($config['proxy']['user']) { curl_setopt($ch, CURLOPT_PROXYUSERPWD, $config['proxy']['user'] . ':' . $config['proxy']['password']); } //curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM); } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->curl_ssl_verifypeer); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->curl_header); if ($type == "POST") { curl_setopt($ch, CURLOPT_POST, 1); if ($params) { curl_setopt($ch, CURLOPT_POSTFIELDS, $params); } } $response = curl_exec($ch); Hybrid_Logger::debug("OAuth2Client::request(). dump request info: ", serialize(curl_getinfo($ch))); Hybrid_Logger::debug("OAuth2Client::request(). dump request result: ", serialize($response)); $this->http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $this->http_info = array_merge($this->http_info, curl_getinfo($ch)); curl_close($ch); return $response; }
/** * define:endpoint step 3.1 and 3.2 */ public static function processAuthDone() { Hybrid_Endpoint::authInit(); // Fix a strange behavior when some provider call back ha endpoint // with /index.php?hauth.done={provider}?{args}... if (strrpos($_SERVER["QUERY_STRING"], '?')) { $_SERVER["QUERY_STRING"] = str_replace("?", "&", $_SERVER["QUERY_STRING"]); parse_str($_SERVER["QUERY_STRING"], Hybrid_Endpoint::$request); } $provider_id = trim(strip_tags(Hybrid_Endpoint::$request["hauth_done"])); $hauth = Hybrid_Auth::setup($provider_id); if (!$hauth) { Hybrid_Logger::error("Endpoint: Invalide parameter on hauth_done!"); $hauth->adapter->setUserUnconnected(); header("HTTP/1.0 404 Not Found"); die("Invalide parameter! Please return to the login page and try again."); } try { Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() "); $hauth->adapter->loginFinish(); } catch (Exception $e) { Hybrid_Logger::error("Exception:" . $e->getMessage(), $e); Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e); $hauth->adapter->setUserUnconnected(); } Hybrid_Logger::info("Endpoint: job done. retrun to callback url."); $hauth->returnToCallbackUrl(); die; }
/** * Define: endpoint step 3.1 and 3.2 * @return void * @throws Hybrid_Exception */ protected function processAuthDone() { $this->authInit(); $provider_id = trim(strip_tags($this->request["hauth_done"])); $hauth = Hybrid_Auth::setup($provider_id); if (!$hauth) { Hybrid_Logger::error("Endpoint: Invalid parameter on hauth_done!"); $hauth->adapter->setUserUnconnected(); throw new Hybrid_Exception("Invalid parameter! Please return to the login page and try again."); } try { Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() "); $hauth->adapter->loginFinish(); } catch (Exception $e) { Hybrid_Logger::error("Exception:" . $e->getMessage(), $e); Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e->getPrevious()); $hauth->adapter->setUserUnconnected(); } Hybrid_Logger::info("Endpoint: job done. return to callback url."); $hauth->returnToCallbackUrl(); die; }
/** * define:endpoint step 3.1 and 3.2 */ protected function processAuthDone() { $provider_id = trim($this->getProperty('hauth_done')); $hauth = Hybrid_Auth::setup($provider_id); if (!$hauth) { Hybrid_Logger::error("Endpoint: Invalid parameter on hauth_done!"); $hauth->adapter->setUserUnconnected(); header("HTTP/1.0 404 Not Found"); return "Invalid parameter! Please return to the login page and try again."; } try { Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() "); $hauth->adapter->loginFinish(); } catch (Exception $e) { Hybrid_Logger::error("Exception:" . $e->getMessage(), $e); Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e); $hauth->adapter->setUserUnconnected(); } Hybrid_Logger::info("Endpoint: job done. retrun to callback url."); // Save profile data in session $profile = $hauth->adapter->getUserProfile(); // Try to get user by social profile /*$q = $this->modx->newQuery('modUser'); $q->innerJoin('modUserProfile', 'Profile'); $q->innerJoin('modHybridAuthUserProfile', 'SocialProfile'); $q->innerJoin('modHybridAuthProvider', 'Provider', "Provider.id=SocialProfile.provider"); $q->where(array( "SocialProfile.identifier" => $profile->identifier, "Provider.name" => $provider, "modUser.active" => 1, "Profile.blocked" => 0, )); $q->limit(1); if($user = $this->modx->getObject('modUser', $q)){ $user->addSessionContext($this->modx->context->key); $redirectTo = $this->modx->getOption('site_url'); $this->modx->sendRedirect($redirectTo); return; }*/ // else $_SESSION['social_profile'] = array('provider' => $provider_id, 'profile' => $this->modx->error->toArray($profile)); //$q->prepare(); //$this->modx->log(1, $q->toSQL()); // else $hauth->returnToCallbackUrl(); return ''; }
/** * define:endpoint step 3.1 and 3.2 */ protected function processAuthDone() { $provider_id = trim($this->getProperty('hauth_done')); $hauth = Hybrid_Auth::setup($provider_id); if (!$hauth) { Hybrid_Logger::error("Endpoint: Invalid parameter on hauth_done!"); $hauth->adapter->setUserUnconnected(); header("HTTP/1.0 404 Not Found"); return "Invalid parameter! Please return to the login page and try again."; } try { Hybrid_Logger::info("Endpoint: call adapter [{$provider_id}] loginFinish() "); $hauth->adapter->loginFinish(); } catch (Exception $e) { Hybrid_Logger::error("Exception:" . $e->getMessage(), $e); Hybrid_Error::setError($e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e); $hauth->adapter->setUserUnconnected(); } Hybrid_Logger::info("Endpoint: job done. retrun to callback url."); // Save profile data in session $profile = $hauth->adapter->getUserProfile(); // else $_SESSION['social_profile'] = array('provider' => $provider_id, 'profile' => $this->modx->error->toArray($profile)); //$q->prepare(); //$this->modx->log(1, $q->toSQL()); // else $hauth->returnToCallbackUrl(); return ''; }
private function request($url, $params = false, $type = "GET") { Hybrid_Logger::info("Enter OAuth2Client::request( {$url} )"); Hybrid_Logger::debug("OAuth2Client::request(). dump request params: ", serialize($params)); if ($type == "GET") { $url = $url . "?" . http_build_query($params); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_time_out); curl_setopt($ch, CURLOPT_USERAGENT, $this->curl_useragent); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->curl_connect_time_out); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->curl_ssl_verifypeer); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->curl_header); if ($type == "POST") { curl_setopt($ch, CURLOPT_POST, 1); if ($params) { curl_setopt($ch, CURLOPT_POSTFIELDS, $params); } } $result = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); Hybrid_Logger::debug("OAuth2Client::request(). dump request info: ", serialize($info)); Hybrid_Logger::debug("OAuth2Client::request(). dump request result: ", serialize($result)); return $result; }
/** * handle : * getUserProfile() * getUserContacts() * getUserActivity() * setUserStatus() */ public function __call($name, $arguments) { Hybrid_Logger::info("Enter Hybrid_Provider_Adapter::{$name}(), Provider: {$this->id}"); if (!$this->isUserConnected()) { throw new Exception("User not connected to the provider {$this->id}.", 7); } if (!method_exists($this->adapter, $name)) { throw new Exception("Call to undefined function Hybrid_Providers_{$this->id}::{$name}()."); } if (count($arguments)) { return $this->adapter->{$name}($arguments[0]); } else { return $this->adapter->{$name}(); } }
/** * Makes an HTTP request. * This method can be overridden by subclasses if * developers want to do fancier things or use something other than curl to * make the request. * * @param string $url * The URL to make the request to * @param array $params * The parameters to use for the POST body * @param CurlHandler $ch * Initialized curl handle * * @return string The response text */ protected function makeRequest($url, $params, $ch = null) { if (!$ch) { $ch = curl_init(); } $opts = self::$CURL_OPTS; if ($this->getFileUploadSupport()) { $opts[CURLOPT_POSTFIELDS] = $params; } else { $opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&'); } $opts[CURLOPT_URL] = $url; // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait // for 2 seconds if the server does not support this header. if (isset($opts[CURLOPT_HTTPHEADER])) { $existing_headers = $opts[CURLOPT_HTTPHEADER]; $existing_headers[] = 'Expect:'; $opts[CURLOPT_HTTPHEADER] = $existing_headers; } else { $opts[CURLOPT_HTTPHEADER] = array('Expect:'); } curl_setopt_array($ch, $opts); $result = curl_exec($ch); if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT self::errorLog('Invalid or no certificate authority found, ' . 'using bundled information'); curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt'); $result = curl_exec($ch); } // With dual stacked DNS responses, it's possible for a server to // have IPv6 enabled but not have IPv6 connectivity. If this is // the case, curl will try IPv4 first and if that fails, then it wills // fall back to IPv6 and the error EHOSTUNREACH is returned by the // operating system. if ($result === false && empty($opts[CURLOPT_IPRESOLVE])) { $matches = array(); $regex = '/Failed to connect to ([^:].*): Network is unreachable/'; if (preg_match($regex, curl_error($ch), $matches)) { if (strlen(@inet_pton($matches[1])) === 16) { self::errorLog('Invalid IPv6 configuration on server, ' . 'Please disable or get native IPv6 on your server.'); self::$CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4; curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); $result = curl_exec($ch); } } } if (class_exists('Hybrid_Logger')) { Hybrid_Logger::info('FB:Request:Response' . print_r(array($url, $result), true)); } if ($result[0] == '{') { $resultOb = json_decode($result); if (key_exists('error', $resultOb)) { if (class_exists('Hybrid_Logger')) { Hybrid_Logger::error('FB:Error' . print_r($resultOb, true)); } } } if ($result === false) { $e = new FacebookApiException(array('error_code' => curl_errno($ch), 'error' => array('message' => curl_error($ch), 'type' => 'CurlException'))); curl_close($ch); throw $e; } curl_close($ch); return $result; }
/** * Utility function, redirect to a given URL with php header or using javascript location.href */ public static function redirect($url, $mode = "PHP") { Hybrid_Logger::info("Enter Hybrid_Auth::redirect( {$url}, {$mode} )"); if ($mode == "PHP") { header("Location: {$url}"); } elseif ($mode == "JS") { echo '<html>'; echo '<head>'; echo '<script type="text/javascript">'; echo 'function redirect(){ window.top.location.href="' . $url . '"; }'; echo '</script>'; echo '</head>'; echo '<body onload="redirect()">'; echo 'Redirecting, please wait...'; echo '</body>'; echo '</html>'; } die; }
/** * Make http request */ function request($url, $method, $postfields = NULL, $auth_header = null) { Hybrid_Logger::info("Enter OAuth1Client::request( {$method}, {$url} )"); Hybrid_Logger::debug("OAuth1Client::request(). dump post fields: ", serialize($postfields)); $this->http_info = array(); $ci = curl_init(); /* Curl settings */ curl_setopt($ci, CURLOPT_USERAGENT, $this->curl_useragent); curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->curl_connect_time_out); $config = Yii::app()->getModule('hybridauth')->getConfig(); if ($config['proxy']) { curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTPS'); curl_setopt($ch, CURLOPT_PROXY, $config['proxy']['url']); curl_setopt($ch, CURLOPT_PROXYPORT, $config['proxy']['port']); if ($config['proxy']['user']) { curl_setopt($ch, CURLOPT_PROXYUSERPWD, $config['proxy']['user'] . ':' . $config['proxy']['password']); } //curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM); } curl_setopt($ci, CURLOPT_TIMEOUT, $this->curl_time_out); curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->curl_ssl_verifypeer); curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader')); curl_setopt($ci, CURLOPT_HEADER, FALSE); switch ($method) { case 'POST': curl_setopt($ci, CURLOPT_POST, TRUE); if (!empty($postfields)) { curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields); } if (!empty($auth_header) && $this->curl_auth_header) { curl_setopt($ci, CURLOPT_HTTPHEADER, array('Content-Type: application/atom+xml', $auth_header)); } 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); Hybrid_Logger::debug("OAuth1Client::request(). dump request info: ", serialize(curl_getinfo($ci))); Hybrid_Logger::debug("OAuth1Client::request(). dump request result: ", serialize($response)); $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE); $this->http_info = array_merge($this->http_info, curl_getinfo($ci)); curl_close($ci); return $response; }