當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。