当前位置: 首页>>代码示例>>PHP>>正文


PHP CHTTP::SetAdditionalHeaders方法代码示例

本文整理汇总了PHP中CHTTP::SetAdditionalHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP CHTTP::SetAdditionalHeaders方法的具体用法?PHP CHTTP::SetAdditionalHeaders怎么用?PHP CHTTP::SetAdditionalHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CHTTP的用法示例。


在下文中一共展示了CHTTP::SetAdditionalHeaders方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SendCommand

	private static function SendCommand($channelId, $message, $options = array())
	{
		if (!is_array($channelId))
			$channelId = Array($channelId);

		$channelId = implode('/', array_unique($channelId));

		if (strlen($channelId) <=0 || strlen($message) <= 0)
			return false;

		$defaultOptions = array(
			"method" => "POST",
			"timeout" => 5,
			"dont_wait_answer" => true
		);

		$options = array_merge($defaultOptions, $options);

		if (!in_array($options["method"], Array('POST', 'GET')))
			return false;

		$nginx_error = COption::GetOptionString("pull", "nginx_error", "N");
		if ($nginx_error != "N")
		{
			$nginx_error = unserialize($nginx_error);
			if (intval($nginx_error['date'])+120 < time())
			{
				COption::SetOptionString("pull", "nginx_error", "N");
				CAdminNotify::DeleteByTag("PULL_ERROR_SEND");
				$nginx_error = "N";
			}
			else if ($nginx_error['count'] >= 10)
			{
				$ar = Array(
					"MESSAGE" => GetMessage('PULL_ERROR_SEND'),
					"TAG" => "PULL_ERROR_SEND",
					"MODULE_ID" => "pull",
				);
				CAdminNotify::Add($ar);
				return false;
			}
		}

		$postdata = CHTTP::PrepareData($message);

		$CHTTP = new CHTTP();
		$CHTTP->http_timeout = intval($options["timeout"]);
		if (isset($options["expiry"]))
		{
			$CHTTP->SetAdditionalHeaders(array("Message-Expiry" => intval($options["expiry"])));
		}

		$arUrl = $CHTTP->ParseURL(CPullOptions::GetPublishUrl($channelId), false);
		if ($CHTTP->Query($options["method"], $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $postdata, $arUrl['proto'], 'N', $options["dont_wait_answer"]))
		{
			$result = $options["dont_wait_answer"] ? '{}': $CHTTP->result;
		}
		else
		{
			if ($nginx_error == "N")
			{
				$nginx_error = Array(
					'count' => 1,
					'date' => time(),
					'date_increment' => time(),
				);
			}
			else if (intval($nginx_error['date_increment'])+1 < time())
			{
				$nginx_error['count'] = intval($nginx_error['count'])+1;
				$nginx_error['date_increment'] = time();
			}
			COption::SetOptionString("pull", "nginx_error", serialize($nginx_error));
			$result = false;
		}

		return $result;
	}
开发者ID:akniyev,项目名称:arteva.ru,代码行数:78,代码来源:pull_channel.php

示例2: createBlankFile

 public function createBlankFile(array $fileData)
 {
     $accessToken = $this->getAccessToken();
     $googleMimeType = $this->getInternalMimeTypeListByExtension(getFileExtension($fileData['name']));
     $fileName = getFileNameWithoutExtension($fileData['name']);
     CWebDavTools::convertToUtf8($fileName);
     if (!$googleMimeType) {
         return false;
     }
     $http = new CHTTP();
     $http->http_timeout = 10;
     $arUrl = $http->ParseURL('https://www.googleapis.com/drive/v2/files');
     $http->SetAdditionalHeaders(array("Authorization" => "Bearer {$accessToken}"));
     $postFields = "{\"title\":\"{$fileName}\",\"mimeType\":\"{$googleMimeType}\"}";
     $postContentType = 'application/json; charset=UTF-8';
     if (!$http->Query('POST', $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $postFields, $arUrl['proto'], $postContentType)) {
         return false;
     }
     $this->checkHttpResponse($http);
     // access token expired, let's get a new one and try again
     if ($http->status == "401") {
         //todo: invalid credential response
         return false;
     }
     // error checking
     if ($http->status != "200") {
         return false;
     }
     $finalOutput = json_decode($http->result);
     //last signed user must delete file from google drive
     $this->insertPermission(array('link' => $finalOutput->alternateLink, 'id' => $finalOutput->id));
     return array('link' => $finalOutput->alternateLink, 'id' => $finalOutput->id);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:33,代码来源:editdocgoogle.php


注:本文中的CHTTP::SetAdditionalHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。