Trying to use Microsoft Azure translator. Have got the necessary keys /see pic/. I work with PHP, so I have got that example from documentation:

$subscription_key = '........;
$endpoint = 'https://api.cognitive.microsofttranslator.com';
//$endpoint = 'https://api-eur.cognitive.microsofttranslator.com';
$path = "/detect?api-version=3.0";

$text = "Salve, mondo!";

if (!function_exists('com_create_guid')) {
function com_create_guid() {
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
mt_rand( 0, 0xffff ),
mt_rand( 0, 0x0fff ) | 0x4000,
mt_rand( 0, 0x3fff ) | 0x8000,
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )

function DictionaryLookup ($host, $path, $key, $params, $content) {

$headers = "Content-type: application/json\r\n" .  
    "Content-length: " . strlen($content) . "\r\n" .  
    "Ocp-Apim-Subscription-Key: $key\r\n" .  
    "X-ClientTraceId: " . com_create_guid() . "\r\n";  
$options = array (  
    'http' => array (  
        'header' => $headers,  
        'method' => 'POST',  
        'content' => $content  
$context  = stream_context_create ($options);  
$result = file_get_contents ($host . $path . $params, false, $context);  
return $result;  

$requestBody = array (
array (
'Text' => $text,
$content = json_encode($requestBody);

$result = DictionaryLookup ($endpoint, $path, $subscription_key, "", $content);

$json = json_encode(json_decode($result), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
echo $json;

I have got this result
Warning: file_get_contents(https://api.cognitive.microsofttranslator.com/detect?api-version=3.0): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in .............../private_html/telegram/detect.php on line 45

The keys are valid, but for some reason just do not work.
What could be the reason?172577-pic1.jpg

Hi, I wasn't able to reproduce this issue. Can you try a service like postman to verify that your key works? Furthermore, please refer to the API reference document. Based on the image provided, it seems you need to use the base url for Europe "api-eur.cognitive.microsofttranslator.com'. If you continue to experience issues, the best option would be to raise a support request for further investigation on account related issues. Thanks.

Hi, tx for trying to help.
Don't know much about Postman.
Can You, pls, check that key 52bfa6fdd1044d878f285ec8e08b1fe1
If it works I'll regenerate it, but I am almost sure it is not.
And if it is the case how can it be that Microsoft Azure provides the invalid keys?

By the way, half a year ago this PHP script worked ok, but at that time it was another Microsoft account...

And I did try this $endpoint = 'https://api-eur.cognitive.microsofttranslator.com'
with no effect.
Judging from the error code it seems to be the key problem.