1

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コードを正しく動作させるには?

4

1 に答える 1