帖子

[资源经验分享] PHP Web API调用总是显示10001错误

[复制链接]

该用户从未签到

27863  楼主| Divine CC、 发表于 2017-10-19 20:58:10 1#
$X_appid = "********";
$api_key = "*****************************";
$url = "http://api.xfyun.cn/v1/aiui/v1/voice_semantic";


$xParam = "{\"auf\": \"16k\", \"aue\": \"raw\", \"scene\": \"main\", \"userid\": \"sdfsdf\"}";
$X_param = base64_encode($xParam);
echo "X_param: " . $X_param . "<br>";

$audio = file_get_contents($result);
//echo "audio: " . $audio . "<br>";
$base_data = base64_encode($audio);

$base_data = "data=" . $base_data;
echo "base_data: " . $base_data . "<br>";
$X_curTime = (string) time();

echo "X_curTime: " . $X_curTime . "<br>";

$checkSum = $api_key . $X_curTime . $X_param . $base_data;
$X_checkSum = md5($checkSum);
echo "X-CheckSum: " . $X_checkSum . "<br>";

$headers = array(
    "Content-Type" => "application/x-www-form-urlencoded; charset=utf-8",
    "X-Appid" => $X_appid,
    "X-CurTime" => $X_curTime,
    "X-Param" => $X_param,
    "X-CheckSum" => $X_checkSum,
);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 2000);
curl_setopt($curl, CURLOPT_TIMEOUT, 2);
curl_setopt($curl, CURLOPT_POSTFIELDS, $base_data);

$response = curl_exec($curl);
echo "response: " . $response;
curl_close($curl);

一天就够 发表于 2017-10-20 15:10:38
2#
我也是一样,一直授权请求头参数为空

楼内回复

https://github.com/IflytekAIUI/DemoCode/tree/master/webapi  详情 发表于 2017-10-20 16:03
dear,感谢您发帖和支持讯飞开放平台论坛,欢迎您加入AIUI开放平台支持群431255925  详情 发表于 2017-10-20 16:01
使用道具 举报 回复
百花 发表于 2017-10-20 16:01:49
3#
一天就够 发表于 2017-10-20 15:10
我也是一样,一直授权请求头参数为空

dear,感谢您发帖和支持讯飞开放平台论坛,欢迎您加入AIUI开放平台支持群431255925
使用道具 举报 回复
百花 发表于 2017-10-20 16:03:04
4#
使用道具 举报 回复