PHP Classes

File: sample.php

Recommend this page to a friend!
  Classes of ravish kumar tiwari   ClickATell SMS Gateway API   sample.php   Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: sample file
Class: ClickATell SMS Gateway API
Send SMS messages using ClickATell
Author: By
Last change:
Date: 13 years ago
Size: 2,976 bytes
 

Contents

Class file image Download
<?php
   
function __autoload($class){
        try{
           
$class = str_replace("_","/",$class);
            if(
file_exists('class/'.$class.'.php')){
                include_once
'class/'.$class.'.php';
            }else{
                throw new
Exception($class.' class does not exist!');
            }
        }catch(
Exception $e){
            echo
$e->getMessage();
            exit(-
1);
        }
    }
   
    if(isset(
$_POST['submit'])){
       
$error='';
        if(!(double)
$_POST['to']==$_POST['to']){
           
$error.="Invalid mobile number.<br />";
        }

        if(!
$_POST['message']){
           
$error.="Please enter message to send...";
        }
       
        if(!
$error){
           
//create new object of SMSSend class
           
$sms = new SMS("YOUR_API_ID","YOUR_CLICKaTELL_USERID","PASSWORD",true,false);
           
$result = $sms->send('+91'.$_POST['to'],'+91'.$_POST['from'], $_POST['message']);
            if(
$result){
                echo
"Message sent : ID is :$result";
            }else{
               
var_dump($result);
            }
        }
    }
   
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title> My SMS Test </title>
        <script type="text/javascript">
            <!-- Begin
            function textCounter(field,cntfield,maxlimit) {
                if (field.value.length > maxlimit){ // if too long...trim it!
                    field.value = field.value.substring(0, maxlimit);
                    // otherwise, update 'characters left' counter
                }else{
                    cntfield.value = maxlimit - field.value.length;
                }
            }
        // End -->
        </script>
    </head>
 <body>
   <h1>My SMS form</h1>
   <?php if(isset($error)){
       echo
'<b>'.$error.'</b>';
      
?>
<?php } ?>
<form method='post' name="messageForm" action='index.php'>
       <table border=0>
           <tr>
             <td>Send to :</td>
             <td>+91<input type='text' maxlength="10" name='to' /></td>
           </tr>
           <tr>
             <td>Froom :</td>
             <td>+91<input type='text' maxlength="10" name='from' /></td>
           </tr>
           <tr>
             <td>Message</td>
             <td>
                 <textarea rows=4 cols=40 name='message' wrap="physical" cols="28" rows="5"
                           onKeyDown="textCounter(document.messageForm.message,document.messageForm.remLen2,150)"
                           onKeyUp="textCounter(document.messageForm.message,document.messageForm.remLen2,150)">
                 </textarea>
                 <br>
                <input readonly type="text" name="remLen2" size="3" maxlength="3" value="150" />characters left
             </td>
           </tr>
           <tr>
             <td> </td>
             <td><input type='submit' name='submit' value='Send' /></td>
           </tr>
       </table>
   </form>
 </body>
</html>