简体   繁体   English

Nexmo语音通话不起作用

[英]Nexmo voice call not working

I have tried to execute the Text to speech API in NEXMO but I an error: 我尝试在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);

But got the new error {"status":"2","error_text":"Missing username"} 但是收到了新错误{"status":"2","error_text":"Missing username"}

Done as per the URL : https://nexmo.github.io/Quickstarts/tts/ . 按照网址完成: https : //nexmo.github.io/Quickstarts/tts/

I have checked all their document. 我已经检查了他们所有的文件。 I don't see such error text. 我没有看到这样的错误文本。 Could anyone help me please? 有人可以帮我吗?

As Marc mentioned, it expects an array for your parameters, rather than a string 正如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);

You can watch this video for a quick walkthrough: Text To Speech Quickstart Video 您可以观看此视频,以进行快速演练: 文本到语音快速入门视频

Full discolsure, I work at Nexmo. 完全公开,我在Nexmo工作。

Here is a more detailed documentation on how to implement Text to Speech 这是有关如何实现文本到语音的更详细的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM