php curl请求谷歌翻译
2013-04-26 13:10
155 查看
英文翻译为中文
/** *Google_API_Translator *请求谷歌翻译接口 */ class Google_API_Translator{ public $outHTML; //返回的HTML /** *翻译 */ function translate(){ $text = urlencode('computer'); //要翻译的词 $google_translator_url = "http://translate.google.com/translate_a/t?client=t&text=".$text."&sl=en&tl=zh_CN"; //拼凑google翻译的api url $html = $this->doPOST($google_translator_url); $this->outHTML = $html; return $this->outHTML; } /** *发送请求 */ function doPost($postUrl){ if($postUrl){ $curl = curl_init(); //开启curl curl_setopt($curl,CURLOPT_URL,$postUrl); //设置请求路径 $html = curl_exec($curl); //执行 if(curl_errno($curl)) $html = '请求错误'; }else{ //路径不能空 $html = '路径不能空'; } return $html; } } $gg = new Google_API_Translator(); $gg->translate();
相关文章推荐
- Google NFC Basics (谷歌官网NFC翻译)
- php curl 发送get和post请求示例
- 谷歌透明度报告:全球政府索要请求达历史新高
- 人工机器:NDC-谷歌机器翻译破世界纪录,仅用Attention模型,无需CNN和RNN
- php curl post请求,java后台用request文件流方式接收
- php curl post请求丢失'+'问题
- [翻译]编写可测试代码-谷歌测试小组博客
- java api1.8中文版(由谷歌,百度,有道,必应翻译)
- 【翻译】ASP.NET MVC深度接触:ASP.NET MVC请求生命周期
- 队名 Booqmz 具体读音可以详见谷歌翻译声优~
- 谷歌扩展程序设置ajax请求允许跨域(极少人知道的解决方案)
- 谷歌为Android应用开发人员提供翻译服务
- 让人爆汗的Google谷歌产品中文翻译大全
- php curl携带 cookie 请求
- 谷歌字体(Google Font)初探 [翻译自Google官方文档]
- PHP curl请求错误汇总和解决方案
- 【翻译】谷歌开发者文档:视觉创意
- GoogleServices之GooglePlayService Accessing Google APIS(访问谷歌APIS)官方文档翻译
- 谷歌开源 tf-seq2seq,你也能用谷歌翻译的框架训练模型
- php curl请求实例