Nexmo 语音通话不工作

Nexmo voice call not working

我尝试在 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/

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

正如 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);

您可以观看此视频进行快速演练:Text To Speech Quickstart Video

完全公开,我在Nexmo工作。

这里有一份关于如何实现的更详细的文档Text to Speech