您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php调用百度翻译api后,调用成功后为什么结果为空?

2024/5/31 10:01:33发布24次查看
$ch = curl_init(); //$keyword='hello'; $url = 'http://apis.baidu.com/apistore/tranlateservice/dictionary?query=hello&from=en&to=zh'; $header = array( 'apikey: 这里是我的apikey,我没有写', ); // 添加apikey到header curl_setopt($ch, curlopt_httpheader , $header); curl_setopt($ch, curlopt_returntransfer, 1); // 执行http请求 curl_setopt($ch , curlopt_url , $url); $res = curl_exec($ch); curl_close($ch); var_dump(json_decode($res));

回复内容: $ch = curl_init(); //$keyword='hello'; $url = 'http://apis.baidu.com/apistore/tranlateservice/dictionary?query=hello&from=en&to=zh'; $header = array( 'apikey: 这里是我的apikey,我没有写', ); // 添加apikey到header curl_setopt($ch, curlopt_httpheader , $header); curl_setopt($ch, curlopt_returntransfer, 1); // 执行http请求 curl_setopt($ch , curlopt_url , $url); $res = curl_exec($ch); curl_close($ch); var_dump(json_decode($res));

因为百度返回给你的结果就是空, 下图为 百度百度提供的调试工具 得到的结果, 和你提供的代码所获得到的结果是一样的.

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product