skip to Main Content

I am looking for a PHP script to send SMS using API‘s like Nexmo / Twillio etc.

Is there any PHP script that I use to send quick SMS messages using Nexmo API?

3

Answers


  1. Nexmo lists two PHP libraries on their Pre-Built Libraries page. Are neither of those suitable?

    Direct links to the two libraries Nexmo recommends:

    Disclaimer – I’ve never used either of those libs, so I can’t vouch for them.

    Login or Signup to reply.
  2. I’ve used the Nexmo-PHP-Lib and was able to send an SMS to a mobile in Canada.

    Login or Signup to reply.
  3. Here is how you can send an sms 🙂

    <?php
    $url = 'https://rest.nexmo.com/sms/json?' . http_build_query([
        'api_key' => API_KEY,
        'api_secret' => API_SECRET,
        'to' => YOUR_NUMBER,
        'from' => NEXMO_NUMBER,
        'text' => 'Hello from Nexmo'
    ]);
    
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    

    API Documentation:

    https://docs.nexmo.com/index.php/sms-api/send-message
    https://nexmo.github.io/Quickstarts/sms/send/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search