wav, rate=>8000, channel=>1, token=>$token, cuid=>74-d0-2b-be-5e-31, url=>$pic_path, callback =>xxxx, //key => $appkey,//app key //file => $pic_path,//上传的音频文件(采样率16k或者8k(rate),采样精度16bit(bit),单声道的pcm或者wav格式的音频) //rate => 8000,//采样率(16000或者8000) //pname => date(ymdhis),//包名 //device_id => ,//标记请求来源的标识,如用户所设备序列号 (sn),imei,mac地址等);//$paramstring = http_build_query($params);$paramstring=json_encode($params);$content = juhecurl($url,$paramstring,1);$result = json_decode($content,true);if($result){ //if($result['error_code']=='0'){ print_r($result); //}else{ // echo $result['error_code'].:.$result['reason']; //}}else{ echo 请求失败;}/** * 请求接口返回内容 * @param string $url [请求的url地址] * @param string $params [请求的参数] * @param int $ipost [是否采用post形式] * @return string */function juhecurl($url,$params=false,$ispost=0){ $size=strlen($params); echo $size; $header = array( content-type: application/json, content-length: . $size, ); $httpinfo = array(); $ch = curl_init(); curl_setopt( $ch, curlopt_http_version , curl_http_version_1_1 ); curl_setopt($ch, curlopt_httpheader, $header); //设置头信息的地方 curl_setopt( $ch, curlopt_useragent , 'juhedata' ); curl_setopt( $ch, curlopt_connecttimeout , 60 ); curl_setopt( $ch, curlopt_timeout , 60); curl_setopt( $ch, curlopt_returntransfer , true ); curl_setopt($ch, curlopt_followlocation, true); if( $ispost ) { curl_setopt( $ch , curlopt_post , true ); curl_setopt( $ch , curlopt_postfields , $params ); curl_setopt( $ch , curlopt_url , $url ); } else { if($params){ curl_setopt( $ch , curlopt_url , $url.'?'.$params ); }else{ curl_setopt( $ch , curlopt_url , $url); } } $response = curl_exec( $ch ); if ($response === false) { //echo curl error: . curl_error($ch); return false; } $httpcode = curl_getinfo( $ch , curlinfo_http_code ); $httpinfo = array_merge( $httpinfo , curl_getinfo( $ch ) ); curl_close( $ch ); return $response;}?>
有人用过吗,是提供url的方式的那种,为什么一直提示的是array
(
[err_msg] => parameters error.[err_no] => 3300[sn] => 967126290621465557773
)
回复内容: wav, rate=>8000, channel=>1, token=>$token, cuid=>74-d0-2b-be-5e-31, url=>$pic_path, callback =>xxxx, //key => $appkey,//app key //file => $pic_path,//上传的音频文件(采样率16k或者8k(rate),采样精度16bit(bit),单声道的pcm或者wav格式的音频) //rate => 8000,//采样率(16000或者8000) //pname => date(ymdhis),//包名 //device_id => ,//标记请求来源的标识,如用户所设备序列号 (sn),imei,mac地址等);//$paramstring = http_build_query($params);$paramstring=json_encode($params);$content = juhecurl($url,$paramstring,1);$result = json_decode($content,true);if($result){ //if($result['error_code']=='0'){ print_r($result); //}else{ // echo $result['error_code'].:.$result['reason']; //}}else{ echo 请求失败;}/** * 请求接口返回内容 * @param string $url [请求的url地址] * @param string $params [请求的参数] * @param int $ipost [是否采用post形式] * @return string */function juhecurl($url,$params=false,$ispost=0){ $size=strlen($params); echo $size; $header = array( content-type: application/json, content-length: . $size, ); $httpinfo = array(); $ch = curl_init(); curl_setopt( $ch, curlopt_http_version , curl_http_version_1_1 ); curl_setopt($ch, curlopt_httpheader, $header); //设置头信息的地方 curl_setopt( $ch, curlopt_useragent , 'juhedata' ); curl_setopt( $ch, curlopt_connecttimeout , 60 ); curl_setopt( $ch, curlopt_timeout , 60); curl_setopt( $ch, curlopt_returntransfer , true ); curl_setopt($ch, curlopt_followlocation, true); if( $ispost ) { curl_setopt( $ch , curlopt_post , true ); curl_setopt( $ch , curlopt_postfields , $params ); curl_setopt( $ch , curlopt_url , $url ); } else { if($params){ curl_setopt( $ch , curlopt_url , $url.'?'.$params ); }else{ curl_setopt( $ch , curlopt_url , $url); } } $response = curl_exec( $ch ); if ($response === false) { //echo curl error: . curl_error($ch); return false; } $httpcode = curl_getinfo( $ch , curlinfo_http_code ); $httpinfo = array_merge( $httpinfo , curl_getinfo( $ch ) ); curl_close( $ch ); return $response;}?>
有人用过吗,是提供url的方式的那种,为什么一直提示的是array
(
[err_msg] => parameters error.[err_no] => 3300[sn] => 967126290621465557773
)
err_msg提示你参数错误,err_no说错误代码是3300,去百度语音识别 - 开发文档找这个错误代码,可以看到:
错误码 含义
3300 输入参数不正确
建议用抓包工具看一下php发出的请求是不是和文档上的相符