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