Comment puis-je utiliser la méthode POST pour Google Translate. Je ne veux pas utiliser JS pour une raison quelconque, besoin de le faire avec PHP. Ce qui suit ne fonctionne pas.Comment puis-je utiliser la méthode POST pour Google Translate
public static function googleTranslatePost($text = "What are you looking at", $destLang='fr', $srcLang = 'en')
{
$http_response = '';
$ch = curl_init('http://translate.google.com/translate_t');
curl_setopt($ch, CURLOPT_POSTFIELDS,'hl=en&ie=UTF8&text=-->this+is+a+test<--&langpair=en%7Car');
curl_setopt($ch, CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_HEADER,false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$http_response = curl_exec($ch);
return $http_response;
}
Que se passe ou ne se passe pas? –
Je ne reçois aucune réponse ni erreur de la part de php. – YumYumYum
TRAVAIL MAINTENANT - https://gist.github.com/728228 – YumYumYum