简体   繁体   中英

Nexmo voice call not working

I have tried to execute the Text to speech API in NEXMO but I an error:

$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"}

Done as per the URL : 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

 $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.

Here is a more detailed documentation on how to implement Text to Speech

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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