我试过相同的代码:
$url = 'https://rest.nexmo.com/sms/json?api_key=KEY&api_secret=SECRET&from=NEXMO&to=TO_NUMBER&text=Welcome+to+Nexmo';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
echo($response);
我得到了回应:
{
"message-count": "1",
"messages": [{
"to": "TO_NUMBER",
"message-id": "MESSAGE_ID",
"status": "0",
"remaining-balance": "7.25697349",
"message-price": "0.03330000",
"network": "23415"
}]
}%
如您所见,响应似乎已填充。所以,它似乎工作。
我个人建议使用nexmo-php库,因为它由 Nexmo(我为之工作)正式支持。
$client = new Nexmo\Client(new Nexmo\Client\Credentials\Basic(API_KEY, API_SECRET));
$message = $client->message()->send([
'to' => NEXMO_TO,
'from' => NEXMO_FROM,
'text' => 'Test message from the Nexmo PHP Client'
]);