Discussions

Ask a Question
Back to All

Авторизация

Здравствуйте, подскажите, пожалуйста, как активировать куна код с помощью php?
У меня вот такой пример:

$token_captcha = explode("OK|", ($recaptcha['token_captcha']));

$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "443",
CURLOPT_URL => "https://api.kuna.io:443/v3/signin",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{"email":"[email protected]","password":"j2'eJeQLj8Qk(kF","g-recaptcha-response":"".$token_captcha[1].""}",
CURLOPT_HTTPHEADER => ["Content-Type: application/json"],]);
$response = curl_exec($curl);

$curl1 = curl_init();

curl_setopt_array($curl1, [
CURLOPT_PORT => "443",
CURLOPT_URL => "https://api.kuna.io:443/v3/auth/verification/auth_token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{"stage":"".$ere[16]."".$ere[17]."".$ere[18]."".$ere[19]."".$ere[20]."".$ere[21]."".$ere[22]."".$ere[23]."".$ere[24]."".$ere[25]."".$ere[26]."".$ere[27]."".$ere[28]."".$ere[29]."".$ere[30]."".$ere[31]."".$ere[32]."".$ere[33]."".$ere[34]."".$ere[35]."".$ere[36]."".$ere[37]."".$ere[38]."".$ere[39]."".$ere[40]."".$ere[41]."".$ere[42]."".$ere[43]."".$ere[44]."".$ere[45]."".$ere[46].""}",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);

$response1 = curl_exec($curl1);
$err = curl_error($curl1);
curl_close($curl1);

$baseurlch2="https://api.kuna.io/v3/auth/kuna_codes/redeem?code=HNbgf-WF4tB-Jg93S-sJk7U-sAeDn-5tBav-gsZZG-cDSjq-jAgqB-UAH-KCode";
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, $baseurlch2);
curl_setopt($ch2, CURLOPT_HEADER, false);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
$response2 = curl_exec($ch2);

В ответ на авторизацию получаю: {"auth_token":"d8311db380cc8aebf14b6ac1a546ce7a"}

В ответ на активацию получаю: {"messages":["not_authorized"]}