Answer the question
In order to leave comments, you need to log in
How to get a token in Bitrix24?
Good afternoon!
Found the following code to get a token from Bitrix24
public function getAccessToken() {
$access_token = false;
/* Авторизуемся на портале */
$this->curl_b24("https://{$this->bitrix24domen}/crm/configs/import/lead.php?LOGIN=". urlencode($this->bitrix24login) . "&PASSWORD=" . urlencode($this->bitrix24password));
$auth_url = $this->curl_b24("https://{$this->bitrix24domen}/oauth/authorize/?client_id=" . $this->client_id . "&response_type=code&redirect_uri=" . $this->url . "/system/library/bitrix24.php", true);
if (preg_match("/\?(.*?)$/i", $auth_url, $arRes)) {
parse_str($arRes[1]);
if (isset($code) && $code != "") {
$res = json_decode($this->curl_b24("https://oauth.bitrix.info/oauth/token/?grant_type=authorization_code&client_id={$this->client_id}&client_secret={$this->client_secret}&code={$code}"));
if ($res->access_token != "") {
$access_token = $res->access_token;
return $access_token;
} else {
$this->getAccessToken();
}
}
}
}
$this->curl_b24("https://{$this->bitrix24domen}/crm/configs/import/lead.php?LOGIN=". urlencode($this->bitrix24login) . "&PASSWORD=" . urlencode($this->bitrix24password));
Answer the question
In order to leave comments, you need to log in
See Bitrix24 REST documentation and how to get/renew tokens -
https://dev.1c-bitrix.ru/learning/course/index.php...
or use PHP SDK - https://github.com/mesilov/bitrix24 -php-sdk
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question