- 论坛徽章:
- 0
|
- $argv = array('text'=>$content, 'hl'=>'zh-CN', 'langpair'=>'zh-CN|en', 'ie'=>'UTF-8');
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_HEADER, false); // 不返回header部分
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 返回字符串,而非直接输出
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // 设置socket连接超时时间
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3');
- curl_setopt($ch, CURLOPT_URL, "http://www.google.com/translate_t?langpair=zh|en");
- curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($argv));
- curl_setopt($ch, CURLOPT_POST, 1)
- curl_exec($ch)
- curl_close($ch);
复制代码
基本就 这样,具体其它选项看手册 |
评分
-
查看全部评分
|