我在 Nexmo 创建了帐户,并从这里尝试了这个示例
<?php
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query(
[
'api_key' => 'API_KEY',
'api_secret' => 'API_SECRET',
'to' => 'HERE REAL NUMBER',
'from' => 'HERE REAL NUMBER',
'text' => 'Hello from Nexmo'
]
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo $response;
但是当我尝试时,这段代码没有回显任何内容
curl "https://rest.nexmo.com/sms/json?api_key=KEY&api_secret=SECRET&from=NEXMO&to=911234567890&text=Welcome+to+Nexmo"
我得到回应
{
"message-count": "1",
"messages": [{
"to": "911234567890",
"message-id": "070000000279DB5A",
"status": "0",
"remaining-balance": "1.96000000",
"message-price": "0.02000000",
"network": "41001"
}]
}
如何使php代码正常工作?