PHP код Google переводчика
<?php function translate($string, $langFrom, $langTo) { $url = 'https://translate.google.ru/translate_a/t'; $queryData = array( 'client' => 'x', 'q' => $string, 'sl' => $langFrom, 'tl' => $langTo ); $options = array( 'http' => array( 'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 YaBrowser/18.6.1.770 Yowser/2.5 Safari/537.36', 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($queryData) ) ); $context = stream_context_create($options); $response = file_get_contents($url, false, $context); return $response; } $result = translate('Hello', 'en', 'ru'); echo $result; // Здравствуйте ?>
Люди пишут…