How to Send SMS With PHP Code

This guide is a guide provided by our iSMS Malaysia Team. You will be given information on how to add SMS functionality to your website and how to send sms with PHP code. This method uses HTTP communication between the SMS Gateway and your website. To send and receive SMS messages from a webpage, you will need to have scripting support enabled on your webserver. The scripting support can be PHP. Below are some examples using PHP scripting.

To understand more about our iSMS API Key features, please visit our Developer API page.


All available features and configurations will be displayed at the iSMS Developer API page. Integrate our SMS API into your PHP application and enjoy our SMS services.

Please click below to find out about other programming language samples.



1. Firstly, register a username and password from iSMS Register Page.


It only requires a few information from you such as username, password and your mobile number. It is free.


After you have register an account, you will need to purchase some credit from iSMS Reload Page, you will receive an email containing the reload PIN if you purchase for the first time.


However, if you purchase more than once, the account is automatically credited. Login to iSMS website and insert the PIN.



2. Now you are ready.


Create a file called api_post.php in your host and paste the code below.(Make sure you had install PHP CURL)

<?php

     //We create our own function to submit our link
     //Certain hosts do not support the usage of "fopen"
     function ismscURL($link){

      $http = curl_init($link);

      curl_setopt($http, CURLOPT_RETURNTRANSFER, TRUE);
      $http_result = curl_exec($http);
      $http_status = curl_getinfo($http, CURLINFO_HTTP_CODE);
      curl_close($http);

      return $http_result;
     }

     if(isset($_POST["submit"])){

      $destination = urlencode($_POST["dest"]);
      $message = $_POST["msg"];
      $message = html_entity_decode($message, ENT_QUOTES, 'utf-8'); 
      $message = urlencode($message);
      
      $username = urlencode("xxx");
      $password = urlencode("xxx");
      $sender_id = urlencode("66300");
      $type = (int)$_POST['type'];

      $fp = "https://www.isms.com.my/isms_send.php";
      $fp .= "?un=$username&pwd=$password&dstno=$destination&msg=$message&type=$type&sendid=$sender_id";
      //echo $fp;
      
      $result = ismscURL($fp);
      echo $result;
     }

     ?>
     <html>
     <head>
     <title>API Sample</title>
     <meta http-equiv="Content-Type" content="utf-8">
     </head>
     <body>
     <form method="post" action="api_post.php">
     Destination: <input name="dest" type="text"><br>
     Message: <textarea name="msg" rows="10"></textarea><br>
     Type: <input type="radio" name="type" value="1" checked> ASCII <input type="radio" name="type" value="2"> Unicode<br>
     <input type="submit" name="submit" value="Send">
     </form>
     </body>
     </html>


Contact Us

Please contact us HERE, if you have any enquiries or looking for any consultation.

Email: sales@mobiweb.com.my

Note to registered users: Please include your Username in the email.

Phone Numbers:

  • 1800 87 7061 (Malaysia Toll Free)
  • +604 642 0621 (Penang, Malaysia)
  • +603 2780 3880 (Line 1 Kuala Lumpur, Malaysia)
  • +603 7980 1388 (Line 2 Kuala Lumpur, Malaysia)

Fax:

  • +604 611 5620 (Penang, Malaysia)
  • +603 7980 2388 (Kuala Lumpur, Malaysia)

Articles

 

SMS Coverage for All Countries Worldwide

A B C D E F G H I J K L M N O P Q R S T U V Y Z
divider