Answer the question
In order to leave comments, you need to log in
Bitrix24 API how to log in automatically?
I’m trying to get data from Bitrix24, but I ran into an authorization problem
. If the user is authorized in the browser, then the script works fine and receives data, but if I log in to the browser again, then when the script is launched, the window for entering the login and password is thrown out
The script needs to be hung on cron and therefore this is not an option
Please tell me how to make authorization, google that does not really help
Answer the question
In order to leave comments, you need to log in
$post = http_build_query([
'AUTH_FORM' => 'Y',
'TYPE' => 'AUTH',
'backurl' =>'/auth/',
'USER_LOGIN' => $login,
'USER_PASSWORD' => $pass,
'USER_REMEMBER' => 'Y'
]);
if(strtolower((substr($url,0,5))=='https')) { // если соединяемся с https
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
}
curl_setopt($ch, CURLOPT_URL, 'https://'.SITE_PORTAL.'/auth/?login=yes');
// cURL будет выводить подробные сообщения о всех производимых действиях
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (Windows; U; Windows NT 5.0; En; rv:1.8.0.2) Gecko/20070306 Firefox/1.0.0.4");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//сохранять полученные COOKIE в файл
curl_setopt($ch, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/restapi/cookie.txt');
$result=curl_exec($ch);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question