КОД:
$data = array(
'key' => 'trnsl.1.1.20190919T120001Z.d754b7a5da841428.846bdf32c23f6295e7a341b8b1dc6e2c0bf31c30',
'text' => 'My name is ...',
'lang' => 'de',
'format' => 'plain',
'options' => 1,
);
$curlObject = curl_init();
curl_setopt($curlObject, CURLOPT_URL, 'https://translate.yandex.net/api/v1.5/tr.json/translate');
curl_setopt($curlObject, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curlObject, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curlObject, CURLOPT_POST, true);
curl_setopt($curlObject, CURLOPT_POSTFIELDS, http_build_query($data,'','&'));
curl_setopt($curlObject, CURLOPT_RETURNTRANSFER, true);
$responseData = curl_exec($curlObject);
curl_close($curlObject);
if ($responseData === false) {
throw new Exception('Response false');
}
var_dump(json_decode($responseData, true));
К примеру, чтоб выводило en-ru:Hello-Привет