Are there any specific authentication requirements for using the Azure Marketplace Translator service in PHP?

To use the Azure Marketplace Translator service in PHP, you need to authenticate your requests by obtaining a subscription key from Azure. This subscription key needs to be included in the headers of your API requests to authenticate and authorize access to the service.

<?php

$subscriptionKey = 'YOUR_SUBSCRIPTION_KEY';

$url = 'https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es';

$text = 'Hello, how are you?';

$requestBody = array(
    array('Text' => $text)
);

$requestHeaders = array(
    'Ocp-Apim-Subscription-Key: ' . $subscriptionKey,
    'Content-Type: application/json'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestBody));
curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);

echo $response;

?>