Guest User

Untitled

a guest
Aug 26th, 2016
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <?php
  2.    
  3.     /** php5-curl and php5-json must be installed **/
  4.    
  5.     function sendRocketSMS($phone, $message, $sender="SMS-Inform") {
  6.         $curl = curl_init();
  7.    
  8.         curl_setopt($curl, CURLOPT_URL, 'http://api.rocketsms.by/json/send');  
  9.         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  10.         curl_setopt($curl, CURLOPT_POST, true);
  11.         curl_setopt($curl, CURLOPT_POSTFIELDS, "username=1234567890&password=qwerty&sender=" . $sender . "&phone=" . $phone . "&text=" . $message);
  12.        
  13.         $result = @json_decode(curl_exec($curl), true);
  14.        
  15.         if ($result && isset($result['id'])) {
  16.             return "Message has been sent. MessageID=" . $result['id'];
  17.         } elseif ($result && isset($result['error'])) {
  18.             return "Error occurred while sending message. ErrorID=" . $result['error'];
  19.         } else {
  20.             return "Service error";
  21.         }
  22.     }
  23.    
  24.     echo "<pre>";  
  25.     echo sendRocketSMS("375297357355", "hello, rocketsms!");   
  26.     echo "</pre>";
Add Comment
Please, Sign In to add comment