PHP 7 Script to Send SMS to Mobile Number Using Nexmo SMS API Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

 

Welcome folks today in this blog post we will be sending sms to mobile number using nexmo sms api in php 7.All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an index.php file and copy paste the following code

See also  PHP 7 Script to Export MySQL Table to CSV File in Browser Using Javascript Full Project For Beginners

 

 

index.php

 

 

<?php

function cspd_send_nexmo_sms($key,$secret,$to_number,$from_number,$sms_text)
{
  $url = 'https://rest.nexmo.com/sms/json?' . http_build_query([
        'api_key' => $key,
        'api_secret' => $secret,
        'to' => $to_number,
        'from' => $from_number,
        'text' => $sms_text
    ]);

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    return curl_exec($ch);
}

?>

Leave a Reply