Location: PHPKode > scripts > Send WAP Push > send-wap-push/SendWP.php
<?php

define("SIGNAL_NONE","signal-none");
define("SIGNAL_LOW","signal-low");
define("SIGNAL_MEDIUM","signal-medium");
define("SIGNAL_HIGH","signal-high");

class sendWP {
    
    
    private $_apiId = null;
    private $_user = null;
    private $_password = null;
    private $_from = null;
    private $_server_api = "http://api.clickatell.com/";
    
    
    function __construct($apiId,$user,$password)
    {
        $this->setApiId($apiId);
        $this->setUser($user);
        $this->setPassword($password);
    }
    
    function setApiId($apiId)
    {
        $this->_apiId = $apiId;
    }
    
    function setUser($user)
    {
        $this->_user = $user;
    }
    
    function setPassword($password)
    {
        $this->_password = $password;
    }
    
    function setFrom($from)
    {
        $this->_from = $from;
    }
    
    function setServerApi($serverApi)
    {
        $this->_server_api = $serverApi;
    }
    
    function getFrom()
    {
        return $this->_from;
    }

    function getApi()
    {
        return $this->_server_api;
    }
    
    function sendWP($from='',$to,$si_url,$si_text='',$si_id='',$si_expires='2009-12-30T00:00:00Z',$si_created='',$si_action=SIGNAL_MEDIUM)
    {
        
        
        $t_regexp = "/\d{4}-\d{1,2}-\d{1,2}T\d{1,2}:\d{1,2}:\d{1,2}Z/";
        
        if (empty($from)) {
            $from = $this->getFrom();
        }

        $from = urlencode($from);
        
        if (empty($si_id)) {
            
            $si_id = substr(md5(time()),1,10); 
        }
        
        if (empty($si_created) || !preg_match($t_regexp,$si_created)) {
            $curDate = date('Y-m-d');
            $curTime = date('H:i:s');
            $si_created = "{$curDate}T{$curTime}Z";
        }
        if (!preg_match($t_regexp,$si_expires)) {
            $si_expires = "2009-12-30T00:00:00Z";
        }
        
        if ($si_action != SIGNAL_NONE || $si_action != SIGNAL_LOW || $si_action != SIGNAL_MEDIUM || $si_action != SIGNAL_HIGH) {
            $si_action = SIGNAL_MEDIUM;
        }
        
        $si_text = urlencode($si_text);
 
        $url=$this->getApi()."mms/si_push?api_id={$this->_apiId}&user={$this->_user}&password={$this->_password}&from={$from}&to={$to}&si_id={$si_id}&si_url={$si_url}&si_created={$si_created}&si_expires={$si_expires}&si_action={$si_action}&si_text={$si_text}";
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
        $output = curl_exec($curl);
                
        if (preg_match("/ID: .+/",$output)) {
            return true;
        } else {
            return false;
        }
        
        
        
    }
    
}
?>
Return current item: Send WAP Push