本文整理汇总了PHP中CHTTP::setAdditionalHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP CHTTP::setAdditionalHeaders方法的具体用法?PHP CHTTP::setAdditionalHeaders怎么用?PHP CHTTP::setAdditionalHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHTTP
的用法示例。
在下文中一共展示了CHTTP::setAdditionalHeaders方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: queryOld
protected function queryOld($scope, $method = "GET", $data = null, $skipRefreshAuth = false)
{
if ($this->engineSettings['AUTH']) {
$http = new \CHTTP();
$http->setAdditionalHeaders(array('Authorization' => 'OAuth ' . $this->engineSettings['AUTH']['access_token']));
$http->setFollowRedirect(false);
switch ($method) {
case 'GET':
$result = $http->get($scope);
break;
case 'POST':
$result = $http->post($scope, $data);
break;
case 'PUT':
$result = $http->httpQuery($method, $scope, $http->prepareData($data));
break;
case 'DELETE':
break;
}
if ($http->status == 401 && !$skipRefreshAuth) {
if ($this->checkAuthExpired(false)) {
$this->queryOld($scope, $method, $data, true);
}
}
$http->result = Text\Encoding::convertEncoding($http->result, 'utf-8', LANG_CHARSET);
return $http;
}
}
示例2: query
protected function query($scope, $method = "GET", $data = null, $bSkipRefreshAuth = false, $contentType = 'application/atom+xml')
{
if ($this->engineSettings['AUTH']) {
$http = new \CHTTP();
$http->setAdditionalHeaders(array('Authorization' => 'Bearer ' . $this->engineSettings['AUTH']['access_token'], 'GData-Version' => '2'));
switch ($method) {
case 'GET':
$result = $http->get($scope);
break;
case 'POST':
case 'PUT':
$arUrl = $http->parseURL($scope);
$result = $http->query($method, $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $data, $arUrl['proto'], $contentType);
break;
case 'DELETE':
break;
}
if ($http->status == 401 && !$bSkipRefreshAuth) {
if ($this->checkAuthExpired(true)) {
return $this->query($scope, $method, $data, true, $contentType);
}
}
return $http;
}
}