无需Api_Key使用百度在线翻译接口
来源:互联网 发布:怎么下载网站的数据库 编辑:程序博客网 时间:2024/06/08 13:05
无需申请Api Key照样使用百度翻译接口!
function wxcurl($url, $fields = array(), $method = 'post',$debug = false) {
$curl = curl_init ();
curl_setopt ( $curl, CURLOPT_URL, $url );
curl_setopt ( $curl, CURLOPT_HTTPHEADER, array (
'Expect:'
) );
curl_setopt ( $curl, CURLOPT_TIMEOUT, 60 );
curl_setopt ( $curl, CURLOPT_MAXREDIRS, 6 );
curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $curl, CURLOPT_FOLLOWLOCATION, true );
//curl_setopt ( $curl, CURLOPT_COOKIEJAR, "/tmp/curl_cookie_file" );
//curl_setopt ( $curl, CURLOPT_COOKIEFILE, "/tmp/curl_cookie_file" );
if (strtolower ( $method ) == 'post') {
curl_setopt ( $curl, CURLOPT_POST, true );
curl_setopt ( $curl, CURLOPT_POSTFIELDS, http_build_query ( $fields ) );
}
curl_setopt ( $curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)' );
$result = curl_exec ( $curl );
if($debug){
echo "=====post data======\r\n";
var_dump($fields);
echo '=====info====='."\r\n";
print_r( curl_getinfo($curl) );
echo '=====$response====='."\r\n";
print_r( $result );
echo '=====error====='."\r\n";
echo curl_error($curl) ;
}
return $result;
}
$data['from'] = 'zh';
$data['query'] = "加油";
$data['simple_means_flag'] = '3';
$data['to'] = 'en';
$arr = wxcurl('http://fanyi.baidu.com/v2transapi', $data);
$array = json_decode($arr,true);
var_dump($array);
- 无需Api_Key使用百度在线翻译接口
- 百度在线翻译
- 各种浏览器在线翻译,无需插件
- 在线翻译
- 在线翻译
- HTML实现调用百度在线翻译API
- C#调用Bing的在线翻译接口Translator
- 百度地图接口及使用
- (Android)百度地图Demo的API_KEY的获取方式问题
- 使用有道API完成在线翻译功能
- API实践:用百度翻译API写一个在线翻译
- 百度网盘使用浏览器下载大文件,无需跳转客户端
- Android开发使用google地图申请api key(v2.API_KEY)
- 如何使用百度天气预报API接口
- 如何使用百度天气预报API接口
- Android中使用百度APIstore接口
- 如何使用百度天气预报API接口
- 百度语音REST接口使用(python)
- ipsec Permission denied
- bzoj1113 [Poi2008]海报PLA
- Centos 安装OpenStack
- git cherry-pick用于把另一个本地分支的commit修改应用到当前分支
- JVMGC机制
- 无需Api_Key使用百度在线翻译接口
- bzoj2718 [Violet 4]毕业旅行
- Github使用之将已有项目提交到Github/从Github上pull到本地
- web缓存机制——浏览器缓存
- 局部变量、全局变量、变量、抽象
- ubuntu 挂载 window 共享文件夹问题
- Volley加载图片
- bzoj3687 简单题
- appium for windows 环境搭建