1

我正在使用VOICECLOUD API进行转录(语音转文本)。我使用 CURL 调用 API。

结果/响应是:(-5 无法保存文件)没有更多详细信息:(

这是我的代码:

function CallAPI($url) {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);

    print_r($result); //Always returns:  -5 could not save file 
}

$url = 'http://api.voicecloud.com/api.cgi?action=sendfile&username=MY+USER+NAME&devkey=11xxxx&idtype=username&fileurl=http://www.EXAMPLE.com/app/recordings/test.mp3&filetype=mp3&callerid=18xxxxxxxx';
CallAPI($url);  
4

1 回答 1

0

API声明您应该通过GET.

所以改变你的$data数组

$val=http_build_query($data);
$url='http://api.voicecloud.com/api.cgi';
$url.=$val;//Appending the params to the URL

并改变你的CALLAPI()喜欢

function CallAPI($method, $url, $data = false) {
    $curl = curl_init();
    //curl_setopt($curl, CURLOPT_POST, 1);//Commmented
    //curl_setopt($curl, CURLOPT_POSTFIELDS, $data);//Commented
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);

    print_r($result);
    curl_close($curl);
}
于 2013-10-26T07:35:27.977 回答