本文整理汇总了PHP中CHTTP::PrepareData方法的典型用法代码示例。如果您正苦于以下问题:PHP CHTTP::PrepareData方法的具体用法?PHP CHTTP::PrepareData怎么用?PHP CHTTP::PrepareData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHTTP
的用法示例。
在下文中一共展示了CHTTP::PrepareData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUrl
/**
* @param string $hash
* @param string $act
* @return string
*/
public function getUrl($hash, $act = "view")
{
return \CHTTP::URN2URI($this->script . (strpos($this->script, "?") === false ? "?" : "&") . \CHTTP::PrepareData(array(self::INFO_NAME => array("CID" => $this->CID, "mode" => $act, "hash" => $hash))));
}
示例2: batch
public function batch($actions)
{
$arBatch = array();
if (is_array($actions)) {
foreach ($actions as $query_key => $arCmd) {
list($cmd, $arParams) = array_values($arCmd);
$arBatch['cmd'][$query_key] = $cmd . '?' . CHTTP::PrepareData($arParams);
}
}
$arBatch['auth'] = $this->access_token;
$batch_url = '/rest/batch';
$httpClient = new \Bitrix\Main\Web\HttpClient();
$result = $httpClient->post($this->portalURI . $batch_url, $arBatch);
return $this->prepareAnswer($result);
}
示例3: Query
private function Query($command, $params = array())
{
if (strlen($command) <= 0 || !is_array($params)) {
return false;
}
$params['BX_COMMAND'] = $command;
$params['BX_LICENCE'] = $this->licenceCode;
$params['BX_DOMAIN'] = $this->domain;
$params['BX_TYPE'] = $this->type;
$params['BX_VERSION'] = $this->version;
$params["BX_HASH"] = $this->RequestSign($this->type, md5(implode("|", $params)));
$CHTTP = new CHTTP();
$arUrl = $CHTTP->ParseURL($this->controllerUrl);
if ($CHTTP->Query('POST', $arUrl['host'], $arUrl['port'], $arUrl['path_query'], CHTTP::PrepareData($params), $arUrl['proto'])) {
$result = json_decode($CHTTP->result);
if (!$result) {
CVoxImplantHistory::WriteToLog($CHTTP->result, 'ERROR QUERY EXECUTE');
}
} else {
$result = json_decode(json_encode(array('error' => array('code' => 'CONNECT_ERROR', 'msg' => 'Parse error or connect error from server'))));
}
return $result;
}
示例4: sendBatch
public function sendBatch($batch)
{
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/update_client.php";
$key = CUpdateClient::GetLicenseKey();
if (strlen($key) > 0 && strlen($batch) > 0) {
$request = new CHTTP();
$arPostData = array("Action" => "SendMessage", "MessageBody" => $batch);
$postdata = CHTTP::PrepareData($arPostData);
$arUrl = $request->ParseURL(self::$remoteProviderUrl . "?key=" . md5($key), false);
$request->Query('POST', $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $postdata, $arUrl['proto'], 'N', true);
return true;
}
return false;
}
示例5: SendCommand
private static function SendCommand($channelId, $message, $method = 'POST', $timeout = 5, $dont_wait_answer = true)
{
if (!is_array($channelId))
$channelId = Array($channelId);
$channelId = implode('/', array_unique($channelId));
if (strlen($channelId) <=0 || strlen($message) <= 0)
return false;
if (!in_array($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($timeout);
$arUrl = $CHTTP->ParseURL(CPullOptions::GetPublishUrl($channelId), false);
if ($CHTTP->Query($method, $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $postdata, $arUrl['proto'], 'N', $dont_wait_answer))
{
$result = $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;
}
示例6: PrepareData
function PrepareData($arPostData, $prefix = '')
{
$str = '';
if (!is_array($arPostData)) {
$str = $arPostData;
} else {
foreach ($arPostData as $key => $value) {
$name = $prefix == "" ? urlencode($key) : $prefix . "[" . urlencode($key) . "]";
if (is_array($value)) {
$str .= CHTTP::PrepareData($value, $name);
} else {
$str .= '&' . $name . '=' . urlencode($value);
}
}
}
if ($prefix == '' && substr($str, 0, 1) == '&') {
$str = substr($str, 1);
}
return $str;
}
示例7: 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);
try {
$sendResult = $CHTTP->Query($options["method"], $arUrl['host'], $arUrl['port'], $arUrl['path_query'], $postdata, $arUrl['proto'], 'N', $options["dont_wait_answer"]);
} catch (Exception $e) {
$sendResult = false;
}
if ($sendResult) {
$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;
}