PHP baidu 翻译 Web模拟接口 非API 永久免费

PHP baidu 翻译 Web模拟接口 非API 永久免费

PHP baidu 翻译 Web模拟接口 非API 永久免费
PHP baidu 翻译 Web模拟接口 非API 永久免费

< ?php $a = 'hi, this my account'; echo sfanyi($a); function sfanyi($content){ if(!$content == NULL) { $apiurl = "http://fanyi.baidu.com/transcontent"; $text = array('ie' => "utf-8",
'source' =>"txt",
'query' => $content,
't' => time(),
'token' => "",
'from' => "en",
'to' => "zh"
);
$fields_string = '';
foreach($text as $key=>$value) {
$fields_string .=$key.'='.$value.'&';
}
rtrim($fields_string, '&');
//echo $fields_string;
$queryurl = $apiurl; //.$query;
$ch = curl_init ($queryurl);
//curl_setopt ($ch,CURLOPT_COOKIEFILE, $ckfile);
curl_setopt ($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch,CURLOPT_REFERER,'http://fanyi.baidu.com/');
curl_setopt ($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22');
curl_setopt ($ch,CURLOPT_POST, count($text));
curl_setopt ($ch,CURLOPT_POSTFIELDS, $fields_string);
$data = curl_exec ($ch);
$out = json_decode($data,true);
return $out['data']['0']['dst']; //$data;
}else {
return false;
}
}
?>

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注