我试图在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"}
根据网址完成:https://nexmo.github.io/Quickstarts/tts/。
我检查了他们所有的文件。我没有看到这样的错误文本。有人可以帮我吗?
答案 0 :(得分: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);
您可以观看此视频,以获得快速演练:Text To Speech Quickstart Video
完全变色,我在Nexmo工作。
以下是有关如何实施Text to Speech