been google\'ing for a while how is the best way to translate with google translator in PHP, found very different ways converting URLS, or using Js but i want to do it only
I have new solution for this.. Because last solution need new version and some fetched other issue.
$text = 'Test new message only.';
$apiKey = '';
$url = 'https://www.googleapis.com/language/translate/v2?key=' . $apiKey . '&q=' . rawurlencode($text) . '&source=en&target=fr';
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($handle);
$responseDecoded = json_decode($response, true);
curl_close($handle);
print_r($responseDecoded['data']['translations'][0]['translatedText']);
die;
//expected output
Testez le nouveau message uniquement.
I hope is very helpful in PHP