Home
Web SMS Client
Outlook SMS Plugin
2-Way SMS
FAQ
Pricing
Developers
APIs for Intergration
Network Technology
Network Coverage
Resources
About Us
Contact Us

User:
Password:
 

info@smsglobal.com.au
tel: 1300 883 400

 

SMSGlobal - API for developers

HTTP API 2.0 Commands List Bulk SMS    

Sample PHP code to send a simle message. Refer to the HTTP API for more functions.

<?php
	$user = "user";
	$pass = "pass";
	$sms_from = "SMSGLOBAL";
	$sms_to = "61409317436";
	$sms_msg = "hello world";
	
	// send sms  
	// returns false if failed  
	// returns $smsglobalmsgid if successful  
	function gw_send_sms($user,$pass,$sms_from,$sms_to,$sms_msg)  
	{  	
		$msg_type = "text";  	
		$unicode = "0";            
		$query_string = "http-api.php?action=sendsms&user=".$user."&password=".$pass;
		$query_string .= "&from=".rawurlencode($sms_from)."&to=".rawurlencode($sms_to);
		$query_string .= "&clientcharset=ISO-8859-1&";
		$query_string .= "text=".rawurlencode(stripslashes($sms_msg)) . "&detectcharset=1";    	
		$url = "http://www.smsglobal.com.au/".$query_string;  	
		$fd = @implode ('', file ($url));  	
		if ($fd)  	
		{  		
			// got response from server  		
			$response = split("; Sent queued message ID:",$fd);  		
			$response1 = split(":",$response[0]);  		
			$smsglobal_status = trim($response1[1]);  		
			$response2 = split(":",$response[1]);  		
			$smsglobalmsgid = trim($response2[1]);    		
			if ($smsglobal_status=="0")  		
			{  			
				// message sent successfully  			
				$ok = $smsglobalmsgid;  		
			}  		
			else   		
			{  			
				// gateway will issue a pause here and output will be delayed  			
				// possible bad user name and password  			
				$ok = false;  		
			}  	
		}  	
		else   	
		{  		
			// no contact with gateway  		
			$ok = false;  	
		}  	
		return $ok;  
	}     

	$msgid = gw_send_sms($user,$pass,$sms_from,$sms_to,$sms_msg);
	if ($msgid)  
	{  	
		echo "<br> sent ok <br>";  	
		echo "message id is $msgid<br>";  
	}  
	else  
	{  	
		echo "<br> not sent <br>";  
	}
?>