la pagina html di translate.google.com è cambiata quindi un codice che si basa sul parsing della pagina (come questo) non può funzionare correttamente
va riadattato il codice altrimenti non potrà mai funzionare
qui c'è una versione enormemente semplificata rispetto a quel codice ma che funziona perfettamente almeno per i test che ho fatto
codice:<?php function ComGoogleTranslate($SourceLanguage, $DestinationLanguage, $Text) { $output = file_get_contents('http://translate.google.com/translate_t?langpair=' . urlencode( $SourceLanguage) . '|' . urlencode($DestinationLanguage) . '&text=' . urlencode($Text)); if ($output == false) { trigger_error("Http request failed", E_USER_WARNING); return false; } if (preg_match('#<span id="?result_box"? class="(short|long)_text">(.*?)</span></div></div>#', $output, $matches) == 0) { trigger_error("Failed to get translated text", E_USER_WARNING); return false; } return strip_tags(str_replace(array(' ',' ',' '), "\r\n", $matches[2])); } echo '<pre>' . ComGoogleTranslate('en', 'it', "I'm a nice guy! Prrrrrr") . '</pre>'; ?>

Rispondi quotando