-2
我正在使用Google翻譯器API。如何增加Google翻譯器API中的翻譯內容大小
function curl($url,$params = array(),$is_coockie_set = false)
{
if(!$is_coockie_set){
/* STEP 1. let’s create a cookie file */
$ckfile = tempnam ("/tmp", "CURLCOOKIE");
/* STEP 2. visit the homepage to set the cookie properly */
$ch = curl_init ($url);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
}
$str = ''; $str_arr= array();
foreach($params as $key => $value)
{
$str_arr[] = urlencode($key)."=".urlencode($value);
}
if(!empty($str_arr))
$str = '?'.implode('&',$str_arr);
/* STEP 3. visit cookiepage.php */
$Url = $url.$str;
$ch = curl_init ($Url);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
return $output;
}
在這個谷歌API,500個字符只有翻譯。
function Translate($word,$conversion)
{
$word = urlencode($word);
$url = 'http://translate.google.com/translate_a/t?client=t&text='.$word.'&hl=en&sl=en&tl=fr&ie=UTF-8&oe=UTF-8&multires=1&otf=1&ssel=3&tsel=3&sc=1';
}
這是用來翻譯內容的函數。我想翻譯超過500個字符。 請指教我。
您使用的是支付的API的免費版本,因爲你必須爲它付出。 https://developers.google.com/translate/v2/faq - 如果您付款; '每個請求的最大字符數是多少? 要翻譯的每個文本的最大大小爲5000個字符,不包括任何HTML標記。 – h2ooooooo