What's new? | Help | Directory | Sign in
Google
osap
OpenMovilforum SMS API in PHP
  
  
  
  
    
Search
for
Updated Apr 12, 2008 by merlos
Labels: send, sample
SendSample  
Example of sending an SMS

In this sample you can see how easily is to send an SMS using OSAP. The steps are:

  1. Create the Net_SMS Object
  2. Create create the Text Message.
  3. Send the message

Lets see those tiny steps in code:

//Set Paths
$delim = (PHP_OS == "WIN32" || PHP_OS == "WINNT") ? ';': ':';
ini_set('include_path', ".{$delim}./pear/" );
unset ($delim);

require_once 'Net/SMS.php';

$sms = new Net_SMS();
//Fill required Params for sending:
//
// 1.- SenderNumber is your Phone number. You need to be a Movistar Spain Client
// 2.- SenderPassword is obtained sending a SMS to 770 number with the text "CLAVE"

$params = array('SenderNumber' => '600123456',
		'SenderPassword' => '123456'
		);
		
//Now Create a Movistar SMS instance
$movistar_sms = $sms->factory('movistar_spain_http',$params);

//Build message
//	id = Not used (net_sms requirement)
//	to = array of recipients
//	message = text message
$message = array( 'id' => '', 'to' => array('+34600123456','600123456'), 'text' => "Txt Message");

//Send It NOW!!!!!!
echo "<pre>";
//echo "---- before send \n";
$r = $movistar_sms->send(&$message);
//echo "---- After send \n";
print_r ($r);

Sign in to add a comment