My favorites | Sign in
Project Logo
                
Search
for
Updated Apr 12, 2008 by merlos
ReceiveTextMessageSample  
Receive Text Messages Sample

Want to know how easy is to receive SMS with this API? The steps are:

  1. Set Path Enviroment if not already done
  2. Set POP3 Server account information
  3. Create the OSAP Object (Net_SMS class)
  4. Retrieve the SMS.

Let's see these steps in code:

<?php
//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 Receiving
// NOTE: if your mail server uses tls, use the "tls://" prefix.
// It will be used a fake gmail account as example

$params = array('POP3Server' => 'tls://pop.gmail.com',
		'POP3Port' => '995',
		'POP3User' => 'username',
		'POP3Pass' => 'password'
		);
		
//Now Create a Movistar SMS instance
$movistar_sms = $sms->factory('movistar_spain_http',$params);

echo "<pre>";

$r = $movistar_sms->countSMS();
if (PEAR::isError($r)) {
	print_r($r);
}

echo 'Number of Messages: ' . $r . "\n";
echo "<b>Message Id List:</b> \n"; 
print_r($movistar_sms->getSMSIds());
echo '<b>Messages</b>' . "\n";
print_r($movistar_sms->getAllSMS());
echo "</pre>";

?>

Sign in to add a comment
Hosted by Google Code