Привет коллеги.
Может у кого подобная ошибка возникала.
Есть скрипт на php который чисто отправляет запрос в несколькими параметрами, вот сам код:
<?php
// Выполнять код нужно двумя отдельными скриптами, сначала запрашиваем sms-код, а в следующем скрипте передаем его для подтверждения
// getcode.php
// 1 этап - отправляем запрос на получения кода в Телеграм приложении
$apiUrl = 'https://api-public.bosslike.ru';
$pubKey = 'abfa1a6c32806c2c945b302c89022a35d572c36bc0729e21';
$method = 'POST';
$url = '/v1/bots/users/me/social/auth/phone/';
$headers = [
'X-Api-Key: '.$pubKey
];
$body = [
'service_type' => 8,
'phone_number' => '79670402563',
];
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_URL, $apiUrl.$url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($body));
$response = json_decode(curl_exec($curl), true);
echo $response;
var_dump($response);
if (isset($response['success']) && $response['success']) {
$token = $response['data']['token'];
}
echo $token;
?>
на php всё работает.
В BAS запрос с этими же параметрами постояно выдаёт ошибку 401
Данные в BAS
Url: https://api-public.bosslike.ru/v1/bots/users/me/social/auth/phone/
Method: POST
Cookie: __cfduid=d4508a57fd01353db30f3f903d58410401609098733
X-Api-Key: abfa1a6c32806c2c945b302c89022a35d572c36bc0729e21
Content-Type: application/x-www-form-urlencoded
Accept: */*
phone_number=79670402563&service_type=8
отдаёт
Url: https://api-public.bosslike.ru/v1/bots/users/me/social/auth/phone/
Status: 401
Date: Sun, 27 Dec 2020 21:21:12 GMT
Content-Type: application/json; charset=UTF-8
Content-Length: 215
Connection: keep-alive
X-Powered-By: PHP/7.2.32
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: https://api-public.bosslike.ru
Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization, Signature, X-Api-Key, X-Api-Signature, X-Api-Timestamp, X-Device-Id, X-User-Agent
CF-Cache-Status: DYNAMIC
cf-request-id: 0747acb8c800008474f783f000000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=t7KHivrYt45XVLeMT2biyVVY2aTk43w3qz5mUZZH9j2NXvCNBfPIDJRBvuv1pwUhLzoTVEFu%2BBbjPU%2F%2Fn8MFYrRB8rfJ62kfONvvT83sdbRzHjiG04hA"}],"group":"cf-nel","max_age":604800}
NEL: {"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 60861707a9708474-LED
{"status":401,"success":false,"errors":[{"code":401,"message":"\u041d\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434\u0443"}]}