1

我尝试在 NEXMO 中执行文本到语音 API,但出现错误:

$phoneno = "Checkthisout";
$params = "api_key=XXXX&api_secret=XXXXX&to=XXXXX&from=XXXXXX&text=".$phoneno;
$url = 'https://api.nexmo.com/tts/json?'; . http_build_query($params);
$ch = curl_init($url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
$response = curl_exec($ch); 
print_r($response);

但是得到了新的错误{"status":"2","error_text":"Missing username"}

根据 URL 完成:https ://nexmo.github.io/Quickstarts/tts/ 。

我检查了他们所有的文件。我没有看到这样的错误文本。有人可以帮我吗?

4

1 回答 1

1

正如 Marc 提到的,它需要一个数组作为参数,而不是字符串

 $params = [
     'api_key' => XXXXX,
     'api_secret' => XXXXX,
     'to' => YOUR_NUMBER,
     'from' => NEXMO_NUMBER,
     'text' => 'Checkthisout',
 ];


 $url = 'https://api.nexmo.com/tts/json?' . http_build_query($params);

 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 $response = curl_exec($ch);

您可以观看此视频进行快速演练:文本到语音快速入门视频

完全公开,我在 Nexmo 工作。

这是有关如何实现文本到语音的更详细的文档

于 2015-07-22T20:02:30.640 回答