Yandex Çeviri API v1.5

$apikey,$nereden,$nereye,$kelime değişkenlerini değiştirerek kullanabilirsiniz.

<?php
	header("Content-Type: text/html;charset=UTF-8");
	//api key için https://translate.yandex.com/developers/keys adresinden create a new key butonuna tıklayınız.
    $apikey = 'trnsl.1.1.xxxxxxxxTxxxxxxZ.xxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
	//desteklenen diller için tıklayınız https://tech.yandex.com/translate/doc/dg/concepts/api-overview-docpage/
	$nereden="en";//İngilizce için en
	$nereye="tr";//Türkçe için tr
	$kelime="Hello";
    $url="https://translate.yandex.net/api/v1.5/tr.json/translate?key=".$apikey."&text=".urlencode($kelime)."&lang=".$nereden."-".$nereye."&format=plain";
	$curl = curl_init($url);
	curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
	$result = json_decode(curl_exec($curl));
	if ($result->code == 200) {
			 echo $result->text[0];
	}
?>

Çıktısı

merhaba

 

Yandex Çeviri API

<?php 
header('Content-Type: text/html; charset=utf-8');
function yandexcevir($text,$from,$to){
$url='http://ceviri.yandex.net/api/v1/tr.json/translate?callback=ya_.json.c(3)&lang=';
$url.=$from."-".$to;
$url.='&text='.rawurlencode($text);
$url.='&srv=tr-text&id=9c7c13c5-0-0&reason=paste&options=4';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);  
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_URL, $url);
$html = curl_exec($ch);
curl_close($ch);
preg_match_all("#\"(.*?)\"#si",$html,$s); 
return str_replace('"',"",$s[0][6]);
}
?>
<form action="" method="post">
<input type="" name="text"/>
<input type="submit" value="Türkçeye Çevir"/>
</form>
<?php
if(isset($_POST["text"])){
echo yandexcevir($_POST["text"],"en","tr");
}
?>