Exemple #1
0
require_once $_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/prolog_before.php";
if (CModule::IncludeModule("socialservices") && CSocServAuthManager::CheckUniqueKey()) {
    if (isset($_REQUEST["authresult"])) {
        $engine = $_REQUEST["engine"];
        \Bitrix\Seo\Service::clearAuth($engine, true);
        ?>
<script type="text/javascript">
	opener.location.reload();
	window.close();
</script>
<?php 
    } else {
        $result = array();
        $state = $_REQUEST["state"];
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '') {
            $engine = \Bitrix\Seo\Service::getEngine();
            $engine->getInterface()->setCode($_REQUEST["code"]);
            if ($engine->getInterface()->GetAccessToken() !== false) {
                $engine->setAuthSettings($engine->getInterface()->getResult());
                $result["result"] = "ok";
            } else {
                $result = $engine->getInterface()->getError();
            }
        } else {
            $result["error"] = "Wrong request";
        }
        Header("Content-Type: application/json");
        echo \Bitrix\Main\Web\Json::encode($result);
    }
}
require_once $_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/main/include/epilog_after.php";
Exemple #2
0
 public function getProxy()
 {
     return Service::getEngine();
 }
Exemple #3
0
 public function call($methodName, $additionalParams = null)
 {
     global $APPLICATION;
     if (!$this->access_token) {
         $interface = Service::getEngine()->getInterface();
         if (!$interface->checkAccessToken()) {
             if ($interface->getNewAccessToken()) {
                 Service::getEngine()->setAuthSettings($interface->getResult());
             } else {
                 return $interface->getResult();
             }
         }
         $this->access_token = $interface->getToken();
     }
     if ($this->access_token) {
         if (!is_array($additionalParams)) {
             $additionalParams = array();
         } else {
             $additionalParams = $APPLICATION->ConvertCharsetArray($additionalParams, LANG_CHARSET, "utf-8");
         }
         $additionalParams['auth'] = $this->access_token;
         $http = new HttpClient(array('socketTimeout' => $this->httpTimeout));
         $result = $http->post(CBitrixSeoOAuthInterface::URL . self::SERVICE_URL . $methodName, $additionalParams);
         /*			AddMessage2Log(array(
         				CBitrixSeoOAuthInterface::URL.self::SERVICE_URL.$methodName,
         				$additionalParams,
         				$http->getStatus(),
         				$result,
         			));*/
         $res = $this->prepareAnswer($result);
         if (!$res) {
             AddMessage2Log('Strange answer from Seo! ' . $http->getStatus() . ' ' . $result);
         }
         return $res;
     } else {
         throw new SystemException("No access token");
     }
 }