本文整理匯總了PHP中HttpClient::getHeader方法的典型用法代碼示例。如果您正苦於以下問題:PHP HttpClient::getHeader方法的具體用法?PHP HttpClient::getHeader怎麽用?PHP HttpClient::getHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HttpClient
的用法示例。
在下文中一共展示了HttpClient::getHeader方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: switchAction
public function switchAction($action, $httpVars, $filesVars)
{
if (!isset($this->actions[$action])) {
return false;
}
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(true)) {
return false;
}
$streamData = $repository->streamData;
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId();
if ($action == "post_to_server") {
$file = base64_decode(AJXP_Utils::decodeSecureMagic($httpVars["file"]));
$target = base64_decode($httpVars["parent_url"]) . "/plugins/editor.pixlr";
$tmp = call_user_func(array($streamData["classname"], "getRealFSReference"), $destStreamURL . $file);
$fData = array("tmp_name" => $tmp, "name" => urlencode(basename($file)), "type" => "image/jpg");
$httpClient = new HttpClient("pixlr.com");
//$httpClient->setDebug(true);
$postData = array();
$httpClient->setHandleRedirects(false);
$params = array("referrer" => "AjaXplorer", "method" => "get", "loc" => ConfService::getLanguage(), "target" => $target . "/fake_save_pixlr.php", "exit" => $target . "/fake_close_pixlr.php", "title" => urlencode(basename($file)), "locktarget" => "false", "locktitle" => "true", "locktype" => "source");
$httpClient->postFile("/editor/", $params, "image", $fData);
$loc = $httpClient->getHeader("location");
header("Location:{$loc}");
} else {
if ($action == "retrieve_pixlr_image") {
$file = AJXP_Utils::decodeSecureMagic($httpVars["original_file"]);
$url = $httpVars["new_url"];
$urlParts = parse_url($url);
$query = $urlParts["query"];
$params = array();
$parameters = parse_str($query, $params);
$image = $params['image'];
/*
$type = $params['type'];
$state = $params['state'];
$filename = $params['title'];
*/
if (strpos($image, "pixlr.com") == 0) {
throw new AJXP_Exception("Invalid Referrer");
}
$headers = get_headers($image, 1);
$content_type = explode("/", $headers['Content-Type']);
if ($content_type[0] != "image") {
throw new AJXP_Exception("File Type");
}
$orig = fopen($image, "r");
$target = fopen($destStreamURL . $file, "w");
while (!feof($orig)) {
fwrite($target, fread($orig, 4096));
}
fclose($orig);
fclose($target);
header("Content-Type:text/plain");
print $mess[115];
}
}
return;
}
示例2: extractResponseCookies
/**
*
* @param HttpClient $client
* @return array
*/
function extractResponseCookies($client)
{
//AJXP_Logger::debug(print_r($client, true));
$cooks = $client->getHeader("set-cookie");
if (empty($cooks)) {
return array();
}
if (is_string($cooks)) {
$cooks = array($cooks);
}
$cookies = array();
foreach ($cooks as $cookieString) {
list($name, $value) = explode("=", $cookieString);
$ar = explode(";", $value);
$value = array_shift($ar);
$cookies[$name] = $value;
}
return $cookies;
}
示例3: switchAction
public function switchAction($action, $httpVars, $filesVars)
{
if (!isset($this->actions[$action])) {
return false;
}
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(true)) {
return false;
}
$streamData = $repository->streamData;
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId();
if ($action == "post_to_server") {
$file = base64_decode($httpVars["file"]);
$file = AJXP_Utils::securePath($file);
$target = base64_decode($httpVars["parent_url"]) . "/plugins/editor.pixlr";
$tmp = call_user_func(array($streamData["classname"], "getRealFSReference"), $destStreamURL . $file);
$tmp = SystemTextEncoding::fromUTF8($tmp);
$fData = array("tmp_name" => $tmp, "name" => urlencode(basename($file)), "type" => "image/jpg");
//var_dump($fData);
$node = new AJXP_Node($destStreamURL . $file);
AJXP_Controller::applyHook("node.read", array($node));
$httpClient = new HttpClient("pixlr.com");
//$httpClient->setDebug(true);
$postData = array();
$httpClient->setHandleRedirects(false);
$saveTarget = $target . "/fake_save_pixlr.php";
if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
$saveTarget = $target . "/fake_save_pixlr_" . md5($httpVars["secure_token"]) . ".php";
}
$params = array("referrer" => "AjaXplorer", "method" => "get", "loc" => ConfService::getLanguage(), "target" => $saveTarget, "exit" => $target . "/fake_close_pixlr.php", "title" => urlencode(basename($file)), "locktarget" => "false", "locktitle" => "true", "locktype" => "source");
$httpClient->postFile("/editor/", $params, "image", $fData);
$loc = $httpClient->getHeader("location");
header("Location:{$loc}");
} else {
if ($action == "retrieve_pixlr_image") {
$file = AJXP_Utils::decodeSecureMagic($httpVars["original_file"]);
$node = new AJXP_Node($destStreamURL . $file);
$node->loadNodeInfo();
AJXP_Controller::applyHook("node.before_change", array(&$node));
$url = $httpVars["new_url"];
$urlParts = parse_url($url);
$query = $urlParts["query"];
if ($this->getFilteredOption("CHECK_SECURITY_TOKEN", $repository->getId())) {
$scriptName = basename($urlParts["path"]);
$token = str_replace(array("fake_save_pixlr_", ".php"), "", $scriptName);
if ($token != md5($httpVars["secure_token"])) {
throw new AJXP_Exception("Invalid Token, this could mean some security problem!");
}
}
$params = array();
parse_str($query, $params);
$image = $params['image'];
$headers = get_headers($image, 1);
$content_type = explode("/", $headers['Content-Type']);
if ($content_type[0] != "image") {
throw new AJXP_Exception("Invalid File Type");
}
$content_length = intval($headers["Content-Length"]);
if ($content_length != 0) {
AJXP_Controller::applyHook("node.before_change", array(&$node, $content_length));
}
$orig = fopen($image, "r");
$target = fopen($destStreamURL . $file, "w");
while (!feof($orig)) {
fwrite($target, fread($orig, 4096));
}
fclose($orig);
fclose($target);
AJXP_Controller::applyHook("node.change", array(&$node, &$node));
//header("Content-Type:text/plain");
//print($mess[115]);
}
}
return;
}
示例4: revokeAccessToken
/**
* revoke access token
*
* @return bool
*/
public function revokeAccessToken()
{
if (!$this->_dataStore->retrieveAccessToken()->getAccessToken()) {
throw new Exception('could not revoke access token, no access token found, did you forgot call autorize()!!');
}
if (!$this->_configuration->getRevokeEndpoint()) {
throw new Exception('no revoke end point found.');
}
$parameters = array('type' => 'web_server', 'client_id' => $this->_client->getClientKey(), 'access_token' => $this->_dataStore->retrieveAccessToken()->getAccessToken());
$http = new HttpClient($this->_configuration->getRevokeEndpoint(), 'POST', http_build_query($parameters));
$http->execute();
$headers = $http->getHeaders();
if ($http->getHeader('http_code') == '200') {
// remove session details access_token, refresh_token, ...
$this->_dataStore->removeAccessToken();
return true;
} else {
return false;
}
}