<?
function getTranslate($text, $toLang = 'en') {
$get = array(
'sl' => 'ru',
'dl' => $toLang,
'text' => trim($text),
);
if(is_callable('curl_init')) {
$ch = curl_init('https://ftapi.pythonanywhere.com/translate?' . http_build_query($get));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
$html = curl_exec($ch);
curl_close($ch);
$return = json_decode($html, true);
if($return['destination-text']) {
return trim($return['destination-text']);
} else {
return false;
}
} else {
return false;
}
}Источник: https://ftapi.pythonanywhere.com
