Beyaz.Net İpucu

Google Translate API Kullanımı

-------------------------------------------------------------TRANSLATE-------------------------------------------------------------------------

$kaynak = $_POST['kaynak'];
$hedef = $_POST['hedef'];

$diller = urlen code($kaynak.'|'.$hedef);
$metin = urlen code($_POST['metin']);

$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".$metin."&langpair=".$diller;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://localhost/translate.php");

$body = curl_exec($ch);
curl_close($ch);

$json = json_decode($body, true);
ech o $json['responseData']['translatedText'];

Kategorideki Güncel Makaleler