public function GetAccessToken() { if (($tokens = $this->getStorageTokens()) && is_array($tokens)) { $this->access_token = $tokens["OATOKEN"]; if ($this->checkAccessToken()) { return true; } } if ($this->code === false) { return false; } $h = new \Bitrix\Main\Web\HttpClient(array("socketTimeout" => $this->httpTimeout)); $h->setAuthorization($this->appID, $this->appSecret); $result = $h->post(self::TOKEN_URL, array("grant_type" => "authorization_code", "code" => $this->code, "client_id" => $this->appID)); $this->arResult = \Bitrix\Main\Web\Json::decode($result); if (isset($this->arResult["access_token"]) && $this->arResult["access_token"] != '') { // yandex doesn't send refresh tokens but I leave it here in case they will if (isset($this->arResult["refresh_token"]) && $this->arResult["refresh_token"] != '') { $this->refresh_token = $this->arResult["refresh_token"]; } $this->access_token = $this->arResult["access_token"]; $this->accessTokenExpires = $this->arResult["expires_in"] + time(); $_SESSION["OAUTH_DATA"] = array("OATOKEN" => $this->access_token); return true; } return false; }
private static function post($url, $data) { $http = new \Bitrix\Main\Web\HttpClient(); $response = $http->post($url, $data); $result = json_decode($response, true); return $result; }
/** * Calls API * @param string $controller Group name * @param string $action Method name * @param mixed $data Input data * @param bool $assoc Result format. true - array, false - object * @return mixed Result * @throws \Exception Case error during requesting */ public function send($controller, $action, $data, $assoc = true) { global $APPLICATION; $http = new \Bitrix\Main\Web\HttpClient(array("version" => "1.1", "socketTimeout" => 30, "streamTimeout" => 30, "redirect" => true, "redirectMax" => 5)); $http->setHeader("Content-Type", "application/json; charset=utf-8"); $http->setHeader("Authorization", "Basic " . base64_encode($this->apiLogin . ":" . $this->apiKey)); if (strtolower(SITE_CHARSET) != 'utf-8') { $data = $APPLICATION->ConvertCharsetArray($data, SITE_CHARSET, 'utf-8'); } $jsonData = json_encode($data); $result = $http->post($this->constructApiUrl($controller, $action), $jsonData); $errors = $http->getError(); if (!$result && !empty($errors)) { $strError = ""; foreach ($errors as $errorCode => $errMes) { $strError .= $errorCode . ": " . $errMes; } throw new \Exception($strError); } else { $status = $http->getStatus(); if ($status != 200) { throw new \Exception(sprintf('HTTP error code: %d', $status)); } $resData = $http->getResult(); $decodedResult = json_decode($resData, $assoc); if (strtolower(SITE_CHARSET) != 'utf-8') { $decodedResult = $APPLICATION->ConvertCharsetArray($decodedResult, 'utf-8', SITE_CHARSET); } } return $decodedResult; }
public static function Ready($callId) { $res = VI\CallTable::getList(array('select' => array('ID', 'CALL_ID', 'CALLER_ID', 'USER_ID', 'TRANSFER_USER_ID', 'ACCESS_URL'), 'filter' => array('=CALL_ID' => $callId))); $call = $res->fetch(); if (!$call) { return false; } $answer['COMMAND'] = 'transfer'; $answer['OPERATOR_ID'] = $call['USER_ID']; $answer['TRANSFER_USER_ID'] = $call['TRANSFER_USER_ID']; $http = new \Bitrix\Main\Web\HttpClient(); $http->waitResponse(false); $http->post($call['ACCESS_URL'], json_encode($answer)); VI\CallTable::update($call['ID'], array('USER_ID' => $call['TRANSFER_USER_ID'], 'TRANSFER_USER_ID' => 0)); CVoxImplantHistory::TransferMessage($call['USER_ID'], $call['TRANSFER_USER_ID'], $call['CALLER_ID']); self::SendPullEvent(array('COMMAND' => 'answerTransfer', 'USER_ID' => $call['USER_ID'], 'CALL_ID' => $call['CALL_ID'])); return true; }
public static function SendCommand($params) { // TODO check $params $res = VI\CallTable::getList(array('select' => array('ID', 'ACCESS_URL'), 'filter' => array('=CALL_ID' => $params['CALL_ID']))); $call = $res->fetch(); if (!$call) { return false; } global $USER; $answer['COMMAND'] = $params['COMMAND']; $answer['OPERATOR_ID'] = $params['OPERATOR_ID'] ? $params['OPERATOR_ID'] : $USER->GetId(); if ($params['COMMAND'] == CVoxImplantIncoming::RULE_WAIT) { } else { if ($params['COMMAND'] == CVoxImplantIncoming::RULE_QUEUE) { } else { if ($params['COMMAND'] == CVoxImplantIncoming::RULE_PSTN) { $answer['PHONE_NUMBER'] = ''; } else { if ($params['COMMAND'] == CVoxImplantIncoming::RULE_USER) { $answer['USER_ID'] = intval($params['USER_ID']); } else { if ($params['COMMAND'] == CVoxImplantIncoming::RULE_VOICEMAIL) { $answer['USER_ID'] = intval($params['USER_ID']); } else { $answer['COMMAND'] = CVoxImplantIncoming::RULE_HUNGUP; } } } } } $http = new \Bitrix\Main\Web\HttpClient(); $http->waitResponse(false); $http->post($call['ACCESS_URL'], json_encode($answer)); return true; }
public function sendMessage($user_id, $uid, $message) { $this->SetOauthKeys($user_id); if ($this->access_token === false) { return false; } $message = CharsetConverter::ConvertCharset($message, LANG_CHARSET, "utf-8"); $arParams = array_merge($this->GetDefParams(), array("oauth_token" => $this->token, "user_id" => $uid, "text" => $message)); $arParams["oauth_signature"] = urlencode($this->BuildSignature($this->GetSignatureString($arParams, self::MESSAGE_URL))); $arHeaders = array("Authorization" => 'OAuth oauth_consumer_key="' . $arParams["oauth_consumer_key"] . '", oauth_nonce="' . $arParams["oauth_nonce"] . '", oauth_signature="' . $arParams["oauth_signature"] . '", oauth_signature_method="HMAC-SHA1", oauth_timestamp="' . $arParams["oauth_timestamp"] . '", oauth_token="' . $this->token . '", oauth_version="1.0"'); $arPost = array("user_id" => $uid, "text" => $message); $ob = new \Bitrix\Main\Web\HttpClient(); foreach ($arHeaders as $header => $value) { $ob->setHeader($header, $value); } return $ob->post(self::MESSAGE_URL, $arPost); }
public function call($methodName, $additionalParams = null) { if (!is_array($additionalParams)) { $additionalParams = array(); } $request = $this->prepareRequest($additionalParams); $http = new \Bitrix\Main\Web\HttpClient(array('socketTimeout' => $this->httpTimeout)); $result = $http->post(CBitrix24NetOAuthInterface::NET_URL . self::SERVICE_URL . $methodName, $request); try { $res = $this->prepareResponse($result); } catch (\Bitrix\Main\ArgumentException $e) { $res = false; } if (!$res) { AddMessage2Log('Strange answer from Network! ' . $http->getStatus() . ' ' . $result); } return $res; }
protected static function send($strParams) { $http = new \Bitrix\Main\Web\HttpClient(array("version" => "1.1", "socketTimeout" => 30, "streamTimeout" => 30, "redirect" => true, "redirectMax" => 5)); $jsnData = $http->post("http://www.pecom.ru/bitrix/components/pecom/calc/ajax.php", $strParams); $errors = $http->getError(); if (!$jsnData && !empty($errors)) { $strError = ""; foreach ($errors as $errorCode => $errMes) { $strError .= $errorCode . ": " . $errMes; } \CEventLog::Add(array("SEVERITY" => "ERROR", "AUDIT_TYPE_ID" => "SALE_DELIVERY", "MODULE_ID" => "sale", "ITEM_ID" => "PECOM_CALCULATOR_SEND", "DESCRIPTION" => $strError)); } return $jsnData; }
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); }
public function getNewAccessToken($refreshToken, $userId = 0, $save = false) { if ($this->appID == false || $this->appSecret == false) { return false; } $httpClient = new \Bitrix\Main\Web\HttpClient(); $result = $httpClient->post(static::TOKEN_URL, array("refresh_token" => $refreshToken, "client_id" => $this->appID, "client_secret" => $this->appSecret, "grant_type" => "refresh_token")); $arResult = \Bitrix\Main\Web\Json::decode($result); if (isset($arResult["access_token"]) && $arResult["access_token"] != '') { $this->access_token = $arResult["access_token"]; $this->accessTokenExpires = $arResult["expires_in"]; if ($save && intval($userId) > 0) { $dbSocservUser = CSocServAuthDB::GetList(array(), array('USER_ID' => intval($userId), "EXTERNAL_AUTH_ID" => static::SERVICE_ID), false, false, array("ID")); if ($arOauth = $dbSocservUser->Fetch()) { CSocServAuthDB::Update($arOauth["ID"], array("OATOKEN" => $this->access_token, "OATOKEN_EXPIRES" => time() + $this->accessTokenExpires)); } } return true; } return false; }
/** * Send request to Bitrix (check o receive) * @param array $payload * @return array|bool */ protected static function sendRequest(array $payload) { $targetHost = static::getServiceHost(); // Trusted host *must* have a valid SSL certificate $skipSslValidation = !in_array($targetHost, static::$trustedHosts, true); $httpClient = new \Bitrix\Main\Web\HttpClient(array('disableSslVerification' => $skipSslValidation, 'streamTimeout' => static::TIMEOUT)); $response = $httpClient->post(self::buildCheckerUrl($targetHost), $payload); if ($response && $httpClient->getStatus() == 200) { return self::decodeResponse($response); } return false; }
public function sendMessage($uid, $message) { if($this->access_token === false) return false; $url = self::GRAPH_URL.'/'.$uid.'/apprequests'; $message = CharsetConverter::ConvertCharset($message, LANG_CHARSET, "utf-8"); $arPost = array("access_token" => $this->access_token, "message"=> $message); $ob = new \Bitrix\Main\Web\HttpClient(); return $ob->post($url, $arPost); }
public function call($methodName, $additionalParams = null) { if (!is_array($additionalParams)) { $additionalParams = array(); } $additionalParams['auth'] = $this->access_token; $http = new \Bitrix\Main\Web\HttpClient(array('socketTimeout' => $this->httpTimeout)); $result = $http->post(CBitrix24NetOAuthInterface::NET_URL . self::SERVICE_URL . $methodName, $additionalParams); $res = $this->prepareAnswer($result); if (!$res) { AddMessage2Log('Strange answer from Network! ' . $http->getStatus() . ' ' . $result); } return $res; }
if (strlen($arFields["DOMAIN"]) <= 0) { $errorMessage .= GetMessage("MFD_ER_DOMAIN") . "<Br>"; } if (strlen($arFields["IP"]) <= 0) { $errorMessage .= GetMessage("MFD_ER_IP") . "<Br>"; } if (strlen($arFields["NAME"]) <= 0) { $errorMessage .= GetMessage("MFD_ER_NAME") . "<Br>"; } if (strlen($arFields["EMAIL"]) <= 0) { $errorMessage .= GetMessage("MFD_ER_EMAIL") . "<Br>"; } if (strlen($arFields["EMAIL"]) > 0 && !check_email($arFields["EMAIL"], true)) { $errorMessage .= GetMessage("MFD_ER_EMAIL2") . "<Br>"; } if ($res = $ht->post("https://www.1c-bitrix.ru/buy_tmp/ddos.php", $arFields)) { if ($ht->getStatus() == "200") { $res = Bitrix\Main\Web\Json::decode($res); if ($res["status"] == "ok") { COption::SetOptionString("main", "~ddos_date", date("Y-m-d")); LocalRedirect($APPLICATION->GetCurPageParam("ok=y", array("ok")) . "#ddf"); } elseif ($res["status"] == "error") { $errorMessage = htmlspecialcharsEx($res["text"]); } } if (strlen($errorMessage) <= 0) { $errorMessage = GetMessage("MFD_ER_ER"); } } } else { $errorMessage = GetMessage("MFD_ER_SESS");
/** * Send request to Bitrix (check o receive) * @param array $payload * @return array|bool */ protected static function sendRequest(array $payload) { $httpClient = new \Bitrix\Main\Web\HttpClient(); $httpClient->setRedirect(true); $httpClient->setStreamTimeout(static::TIMEOUT); $response = $httpClient->post(self::getCheckerUrl(), $payload); if ($response && $httpClient->getStatus() == 200) { return self::decodeResponse($response); } return false; }
public static function CallHold($callId, $result = false) { $res = VI\CallTable::getList(array('select' => array('ID', 'CALL_ID', 'CALLER_ID', 'USER_ID', 'TRANSFER_USER_ID', 'ACCESS_URL'), 'filter' => array('=CALL_ID' => $callId))); $call = $res->fetch(); if (!$call) { return false; } $answer['COMMAND'] = $result ? 'hold' : 'unhold'; $answer['OPERATOR_ID'] = $call['USER_ID']; $http = new \Bitrix\Main\Web\HttpClient(); $http->waitResponse(false); $http->post($call['ACCESS_URL'], json_encode($answer)); self::SendPullEvent(array('COMMAND' => $result ? 'hold' : 'unhold', 'USER_ID' => $call['USER_ID'], 'CALL_ID' => $call['CALL_ID'])); return true; }
public function sendMessage($uid, $message) { if ($this->access_token === false) { return false; } $url = self::MESSAGE_URL; $message = CharsetConverter::ConvertCharset($message, LANG_CHARSET, "utf-8"); $arPost = array("user_id" => $uid, "access_token" => $this->access_token, "message" => $message); $ob = new \Bitrix\Main\Web\HttpClient(); return $ob->post($url, $arPost); }
public function payOrder($orderData = array()) { if (strlen($this->token) > 0) { global $APPLICATION; $url = "https://api-3t." . $this->domain . "paypal.com/nvp"; $arFields = array("METHOD" => "GetExpressCheckoutDetails", "VERSION" => $this->version, "USER" => $this->username, "PWD" => $this->pwd, "SIGNATURE" => $this->signature, "TOKEN" => $this->token, "buttonsource" => "Bitrix_Cart"); $ht = new \Bitrix\Main\Web\HttpClient(array("version" => "1.1")); if ($res = $ht->post($url, $arFields)) { $result = $this->parseResult($res); if ($result["ACK"] == "Success" && in_array($result["CHECKOUTSTATUS"], array("PaymentActionNotInitiated"))) { $arFields["METHOD"] = "DoExpressCheckoutPayment"; $arFields["PAYERID"] = $this->payerId; $arFields["PAYMENTACTION"] = "Sale"; $arFields["PAYMENTREQUEST_0_AMT"] = number_format($this->orderAmount, 2, ".", ""); $arFields["PAYMENTREQUEST_0_CURRENCYCODE"] = $this->currency; $arFields["PAYMENTREQUEST_0_DESC"] = "Order #" . $this->orderId; $arFields["PAYMENTREQUEST_0_NOTETEX"] = "Order #" . $this->orderId; $arFields["PAYMENTREQUEST_0_INVNUM"] = $this->orderId; if (DoubleVal($this->deliveryAmount) > 0) { $arFields["PAYMENTREQUEST_0_SHIPPINGAMT"] = number_format($this->deliveryAmount, 2, ".", ""); } $orderProps = $this->getProps(); if (!empty($orderProps)) { $arFields["PAYMENTREQUEST_0_SHIPTONAME"] = $APPLICATION->ConvertCharset($orderProps["PP_SOURCE"]["PAYMENTREQUEST_0_SHIPTONAME"], SITE_CHARSET, "utf-8"); $arFields["PAYMENTREQUEST_0_SHIPTOSTREET"] = $APPLICATION->ConvertCharset($orderProps["PP_SOURCE"]["PAYMENTREQUEST_0_SHIPTOSTREET"], SITE_CHARSET, "utf-8"); $arFields["PAYMENTREQUEST_0_SHIPTOSTREET2"] = $APPLICATION->ConvertCharset($orderProps["PP_SOURCE"]["PAYMENTREQUEST_0_SHIPTOSTREET2"], SITE_CHARSET, "utf-8"); $arFields["PAYMENTREQUEST_0_SHIPTOCITY"] = $APPLICATION->ConvertCharset($orderProps["PP_SOURCE"]["PAYMENTREQUEST_0_SHIPTOCITY"], SITE_CHARSET, "utf-8"); $arFields["PAYMENTREQUEST_0_SHIPTOSTATE"] = $APPLICATION->ConvertCharset($orderProps["PP_SOURCE"]["PAYMENTREQUEST_0_SHIPTOSTATE"], SITE_CHARSET, "utf-8"); $arFields["PAYMENTREQUEST_0_SHIPTOZIP"] = $orderProps["PP_SOURCE"]["PAYMENTREQUEST_0_SHIPTOZIP"]; $arFields["PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE"] = $APPLICATION->ConvertCharset($orderProps["PP_SOURCE"]["PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE"], SITE_CHARSET, "utf-8"); } if (!empty($orderData["BASKET_ITEMS"])) { $arFields["PAYMENTREQUEST_0_ITEMAMT"] = number_format($this->orderAmount - $this->deliveryAmount, 2, ".", ""); foreach ($orderData["BASKET_ITEMS"] as $k => $val) { $arFields["L_PAYMENTREQUEST_0_NAME" . $k] = $APPLICATION->ConvertCharset($val["NAME"], SITE_CHARSET, "utf-8"); $arFields["L_PAYMENTREQUEST_0_AMT" . $k] = number_format($val["PRICE"], 2, ".", ""); $arFields["L_PAYMENTREQUEST_0_QTY" . $k] = $val["QUANTITY"]; $arFields["L_PAYMENTREQUEST_0_NUMBER" . $k] = $val["PRODUCT_ID"]; } } if (strlen($this->notifyUrl) > 0) { $arFields["PAYMENTREQUEST_0_NOTIFYURL"] = $this->notifyUrl; } if ($res2 = $ht->Post($url, $arFields)) { $result2 = $this->parseResult($res2); if ($result2["ACK"] == "Success" && in_array($result2["PAYMENTINFO_0_PAYMENTSTATUS"], array("Completed"))) { CSaleOrder::PayOrder($this->orderId, "Y"); $strPS_STATUS_MESSAGE = ""; $strPS_STATUS_MESSAGE .= "Name: " . $result["FIRSTNAME"] . " " . $result["LASTNAME"] . "; "; $strPS_STATUS_MESSAGE .= "Email: " . $result["EMAIL"] . "; "; $strPS_STATUS_DESCRIPTION = ""; $strPS_STATUS_DESCRIPTION .= "Payment status: " . $result2["PAYMENTINFO_0_PAYMENTSTATUS"] . "; "; $strPS_STATUS_DESCRIPTION .= "Payment sate: " . $result2["PAYMENTINFO_0_ORDERTIME"] . "; "; $arOrderFields = array("PS_STATUS" => "Y", "PS_STATUS_CODE" => "-", "PS_STATUS_DESCRIPTION" => $strPS_STATUS_DESCRIPTION, "PS_STATUS_MESSAGE" => $strPS_STATUS_MESSAGE, "PS_SUM" => $result2["PAYMENTINFO_0_AMT"], "PS_CURRENCY" => $result2["PAYMENTINFO_0_CURRENCYCODE"], "PS_RESPONSE_DATE" => ConvertTimeStamp(false, "FULL"), "PAY_VOUCHER_NUM" => $result2["PAYMENTINFO_0_TRANSACTIONID"], "PAY_VOUCHER_DATE" => ConvertTimeStamp(false, "FULL")); } else { $strPS_STATUS_MESSAGE = ""; $strPS_STATUS_MESSAGE .= "Name: " . $result["FIRSTNAME"] . " " . $result["LASTNAME"] . "; "; $strPS_STATUS_MESSAGE .= "Email: " . $result["EMAIL"] . "; "; $strPS_STATUS_DESCRIPTION = ""; $strPS_STATUS_DESCRIPTION .= "Payment status: " . $result2["PAYMENTINFO_0_PAYMENTSTATUS"] . "; "; $strPS_STATUS_DESCRIPTION .= "Pending reason: " . $result2["PAYMENTINFO_0_PENDINGREASON"] . "; "; $strPS_STATUS_DESCRIPTION .= "Payment sate: " . $result2["PAYMENTINFO_0_ORDERTIME"] . "; "; $arOrderFields = array("PS_STATUS" => "N", "PS_STATUS_CODE" => $result2["PAYMENTINFO_0_PAYMENTSTATUS"], "PS_STATUS_DESCRIPTION" => $strPS_STATUS_DESCRIPTION, "PS_STATUS_MESSAGE" => $strPS_STATUS_MESSAGE, "PS_SUM" => $result2["PAYMENTINFO_0_AMT"], "PS_CURRENCY" => $result2["PAYMENTINFO_0_CURRENCYCODE"], "PS_RESPONSE_DATE" => ConvertTimeStamp(false, "FULL"), "PAY_VOUCHER_NUM" => $result2["PAYMENTINFO_0_TRANSACTIONID"], "PAY_VOUCHER_DATE" => ConvertTimeStamp(false, "FULL")); } CSaleOrder::Update($this->orderId, $arOrderFields); } } } } }
private static function query($query, $data) { $http = new \Bitrix\Main\Web\HttpClient(); $response = $http->post($query, $data); $xml = new CDataXML(); $xml->loadString($response); return $xml; }
public function GetAccessToken($redirect_uri) { $tokens = $this->getStorageTokens(); if (is_array($tokens)) { $this->access_token = $tokens["OATOKEN"]; if (!$this->code) { return true; } $this->deleteStorageTokens(); } if ($this->code === false) { return false; } $h = new \Bitrix\Main\Web\HttpClient(); $result = $h->post(static::TOKEN_URL, array("code" => $this->code, "client_id" => $this->appID, "client_secret" => $this->appSecret, "redirect_uri" => $redirect_uri, "grant_type" => "authorization_code")); $this->oauthResult = \Bitrix\Main\Web\Json::decode($result); if (isset($this->oauthResult["access_token"]) && $this->oauthResult["access_token"] != '') { if (isset($this->oauthResult["refresh_token"]) && $this->oauthResult["refresh_token"] != '') { $this->refresh_token = $this->oauthResult["refresh_token"]; } $this->access_token = $this->oauthResult["access_token"]; $_SESSION["OAUTH_DATA"] = array("OATOKEN" => $this->access_token); return true; } return false; }
public function call($methodName, $additionalParams = null) { if (!is_array($additionalParams)) { $additionalParams = array(); } $additionalParams['auth'] = $this->access_token; $http = new \Bitrix\Main\Web\HttpClient(array('socketTimeout' => $this->httpTimeout)); $result = $http->post(CBitrix24NetOAuthInterface::NET_URL . self::SERVICE_URL . $methodName, $additionalParams); return $this->prepareAnswer($result); }
<?php } } } ?> <div style="position: relative; padding: 25px; border: 1px solid #859f4a; border-radius: 4px; margin-top: 40px;"> <div style="font-size: 18px; line-height: 28px; position: absolute; top: -14px; left: 14px; display: block; height: 28px; margin: 0; padding: 0; padding: 0 10px; vertical-align: middle; color: #859f4a; background: #fff; font-weight: bold;"><?php echo GetMessage("BUY_SUP_TOBUY"); ?> </div> <?php $ht = new Bitrix\Main\Web\HttpClient(array("socketTimeout" => 30)); $arF = array("license_key" => $lkeySign, "lang" => LANGUAGE_ID); $buyUrl = ""; if ($res = $ht->post("https://www.1c-bitrix.ru/buy_tmp/key_update.php", $arF)) { if ($ht->getStatus() == "200") { $res = Bitrix\Main\Web\Json::decode($res); if ($res["result"] == "ok") { ?> <div style="font-size: 16px; padding-top: 10px;"><?php $lkid = $res["lkid"]; if (count($res["toBuy"]) == 1) { foreach ($res["toBuy"] as $v) { echo $v["NAME"] . " — <b>" . $res["price"] . "</b>"; } } else { foreach ($res["toBuy"] as $v) { echo $v["NAME"]; if (IntVal($v["CNT"]) > 0) { echo " - " . $v["CNT"] . " " . GetMessage("BUY_SUP_SHT");
public static function Decline($callId, $send = true) { $res = VI\CallTable::getList(array('select' => array('ID', 'CALL_ID', 'USER_ID', 'TRANSFER_USER_ID', 'ACCESS_URL'), 'filter' => array('=CALL_ID' => $callId))); $call = $res->fetch(); if (!$call) { return false; } VI\CallTable::update($call['ID'], array('TRANSFER_USER_ID' => 0)); if ($send) { $command['COMMAND'] = 'declineTransfer'; $command['OPERATOR_ID'] = $call['USER_ID']; $http = new \Bitrix\Main\Web\HttpClient(); $http->waitResponse(false); $http->post($call['ACCESS_URL'], json_encode($command)); } self::SendPullEvent(array('COMMAND' => 'declineTransfer', 'USER_ID' => $call['USER_ID'], 'CALL_ID' => $call['CALL_ID'])); self::SendPullEvent(array('COMMAND' => 'timeoutTransfer', 'USER_ID' => $call['TRANSFER_USER_ID'], 'CALL_ID' => $call['CALL_ID'])); return true; }
<?php require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; $httpClient = new \Bitrix\Main\Web\HttpClient(); $request = \Bitrix\Main\Context::getCurrent()->getRequest(); $data['text'] = $request->get('text'); if (\Bitrix\Main\Application::getInstance()->isUtfMode()) { $data['chr'] = 'UTF-8'; } $response = $httpClient->post('http://www.typograf.ru/webservice/', $data); echo $response; require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";