本文整理汇总了PHP中HttpClient::getHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpClient::getHeaders方法的具体用法?PHP HttpClient::getHeaders怎么用?PHP HttpClient::getHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient::getHeaders方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
/**
* Adds static header(s) to the HTTP request headers
*
* @param HttpClient $request HTTP channel object.
*
* @return \HTTP_Request2
*/
public function handleRequest($request)
{
foreach ($this->_headers as $key => $value) {
$headers = $request->getHeaders();
if (!array_key_exists($key, $headers)) {
$request->setHeader($key, $value);
}
}
return $request;
}
示例2: handleRequest
/**
* Adds authentication header to the request headers.
*
* @param HttpClient $request HTTP channel object.
*
* @return \HTTP_Request2
*/
public function handleRequest($request)
{
$signedKey = $this->_sharedKeyAuthentication->getAuthorizationHeader($request->getHeaders(), $request->getUrl(), $request->getUrl()->getQueryVariables(), $request->getMethod());
$request->setHeader(Resources::AUTHENTICATION, $signedKey);
return $request;
}
示例3: _parseAccessTokenResponse
/**
* parse the response of an access token request and store it in dataStore
*
* @param \OAuth2\HttpClient $http
* @param string $oldRefreshToken
* @return \OAuth2\Token
*/
private function _parseAccessTokenResponse(HttpClient $http, $oldRefreshToken = null)
{
$headers = $http->getHeaders();
$type = 'text';
if (isset($headers['Content-Type']) && strpos($headers['Content-Type'], 'application/json') !== false) {
$type = 'json';
}
switch ($type) {
case 'json':
$response = json_decode($http->getResponse(), true);
break;
case 'text':
default:
$response = HttpClient::parseStringToArray($http->getResponse(), '&', '=');
break;
}
if (isset($response['error'])) {
throw new Exception('got error while requesting access token: ' . $response['error']);
}
if (!isset($response['access_token'])) {
throw new Exception('no access_token found');
}
$token = new Token($response['access_token'], isset($response['refresh_token']) ? $response['refresh_token'] : $oldRefreshToken, isset($response['expires_in']) ? $response['expires_in'] : null);
unset($response['access_token']);
unset($response['refresh_token']);
unset($response['expires_in']);
// add additional parameters which may be returned depending on service and scope
foreach ($response as $key => $value) {
$token->{'set' . $key}($value);
}
$this->_dataStore->storeAccessToken($token);
return $token;
}
示例4: startAction
//.........这里部分代码省略.........
$NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
$resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
if ($this->m_ssl == "true") {
$resultMsg .= "<br>귀하의 서버는 SSL통신을 지원하지 않습니다. 결제처리파일에서 m_ssl=false로 셋팅하고 시도하세오.";
$this->MakeErrorMsg(ERR_SSLCONN, $resultMsg);
} else {
$this->MakeErrorMsg(ERR_CONN, $resultMsg);
}
$NICELog->CloseNiceLog("");
return;
}
//request
if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog)) {
// 요청 오류시 처리
$NICELog->WriteLog('POST Error!!' . $httpclient->getErrorMsg());
$this->MakeErrorMsg(ERR_NO_RESPONSE, "서버 응답 오류");
//NET CANCEL Start---------------------------------
if ($httpclient->getErrorCode() == READ_TIMEOUT_ERR) {
$NICELog->WriteLog("Net Cancel Start");
$this->m_uri = "/lite/cancelProcess.jsp";
unset($this->m_queryString);
$this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
$this->m_queryString["TID"] = $this->m_TID;
$this->m_queryString["CancelAmt"] = $this->m_NetCancelAmt;
$this->m_queryString["CancelMsg"] = "NICE_NET_CANCEL";
$this->m_queryString["CancelPwd"] = $this->m_NetCancelPW;
$this->m_queryString["NetCancelCode"] = "1";
$NICELog->WriteLog($this->m_queryString["TID"]);
if (!$httpclient->HttpConnect($NICELog)) {
$NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
$resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
$this->MakeErrorMsg(ERR_CONN, $resultMsg);
$NICELog->CloseNiceLog($this->m_resultMsg);
return;
}
if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog) && $httpclient->getErrorCode() == READ_TIMEOUT_ERR) {
$NICELog->WriteLog("Net Cancel FAIL");
if ($this->m_ActionType == "PYO") {
$this->MakeErrorMsg(ERR_NO_RESPONSE, "승인여부 확인요망");
} else {
if ($this->m_ActionType == "CLO") {
$this->MakeErrorMsg(ERR_NO_RESPONSE, "취소여부 확인요망");
}
}
} else {
$NICELog->WriteLog("Net Cancel SUCESS");
}
}
//NET CANCEL End---------------------------------
$this->ParseMsg($httpclient->getBody(), $NICELog);
$NICELog->CloseNiceLog($this->m_resultMsg);
return;
}
if ($httpclient->getStatus() == "200") {
$this->ParseMsg($httpclient->getBody(), $NICELog);
$NICELog->WriteLog("TID -> " . "[" . $this->m_ResultData['TID'] . "]");
$NICELog->WriteLog($this->m_ResultData['ResultCode'] . "[" . $this->m_ResultData['ResultMsg'] . "]");
$NICELog->CloseNiceLog("");
} else {
$NICELog->WriteLog('SERVER CONNECT FAIL:' . $httpclient->getStatus() . $httpclient->getErrorMsg() . $httpclient->getHeaders());
$resultMsg = $httpclient->getStatus() . "서버에러가 발생했습니다.";
$this->MakeErrorMsg(ERR_NO_RESPONSE, $resultMsg);
//NET CANCEL Start---------------------------------
if ($httpclient->getStatus() != 200) {
$NICELog->WriteLog("Net Cancel Start");
//Set Field
$this->m_uri = "/lite/cancelProcess.jsp";
unset($this->m_queryString);
$this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
$this->m_queryString["TID"] = $this->m_TID;
$this->m_queryString["CancelAmt"] = $this->m_NetCancelAmt;
$this->m_queryString["CancelMsg"] = "NICE_NET_CANCEL";
$this->m_queryString["CancelPwd"] = $this->m_NetCancelPW;
$this->m_queryString["NetCancelCode"] = "1";
if (!$httpclient->HttpConnect($NICELog)) {
$NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
$resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
$this->MakeErrorMsg(ERR_CONN, $resultMsg);
$NICELog->CloseNiceLog($this->m_resultMsg);
return;
}
if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog)) {
$NICELog->WriteLog("Net Cancel FAIL");
if ($this->m_ActionType == "PYO") {
$this->MakeErrorMsg(ERR_NO_RESPONSE, "승인여부 확인요망");
} else {
if ($this->m_ActionType == "CLO") {
$this->MakeErrorMsg(ERR_NO_RESPONSE, "취소여부 확인요망");
}
}
} else {
$NICELog->WriteLog("Net Cancel SUCESS");
}
}
//NET CANCEL End---------------------------------
$this->ParseMsg($httpclient->getBody(), $NICELog);
$NICELog->CloseNiceLog("");
return;
}
}