Alarmas Sms (gracias a google)

Hola el otro dia vi en el blog de Ivan L?pez como usaba las alarmas del google calendar, para enviarse SMS al m?vil con ‘alertas’, y as? poder tener controlado sus servidores.
El ‘problema’, es que esta en java, as? que decid? hacer lo mismo pero en php, para que mas gente pudiese usarlo.

El modo de empleo es el mismo, necesitas PHP 5.1.4 o superior (son las necesarias para usar la API) y las librer?as ZEND de Gdata.

Para mas informaci?n del uso de la API se puede mirar directamente a la web de google code.

/*
** Generador de alertas sms a traves de google
** Basado en el de Ivan Lopez (lopezivan.blogspot.com)
** Elias Badenes, 2007
** elias (at) badenes (dot) es
*/
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');

function crearAlerta($cliente, $texto) {
$dia? = date('Y-m-d');
$hIni = date('H:i', strtotime('now +6 minutes'));
$hFin = date('H:i', strtotime('now +7 minute'));

$gdataCal = new Zend_Gdata_Calendar($cliente);
$evento?? = $gdataCal->newEventEntry();
$startDate = $dia;
$endDate?? = $dia;
$tzOffset? = '+02'; //en verano '+02' en invierno '+01'
$startTime = $hIni;
$endTime?? = $hFin;

//asigno el texto
$evento->title = $gdataCal->newTitle($texto);

//Asigno el tiempo
$cuando = $gdataCal->newWhen();
$cuando->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00";
$cuando->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00";

//alerta sms
$metodo = 'sms'; //alert, email o sms
$alerta = $gdataCal->newReminder();
$alerta->setMinutes(5);
$alerta->setMethod('sms');
$cuando->setReminders(array($alerta));

$evento->when = array($cuando);

echo 'Insertando Alerta: '.$texto."n";
$a = $gdataCal->insertEvent($evento);
}

if(count($argv) < 4) {
echo "Uso: $argv[0] <usuario> <password> <texto>n";
die();
}

$usuario? = $argv[1];
$password = $argv[2];
$texto??? = '';
$argc???? = count($argv);

for( $i=3; $i>$argc; $i++) {
$texto .= $argv[$i].' ';
}

$servicio = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$cliente? = Zend_Gdata_ClientLogin::getHttpClient($usuario, $password, $servicio);
crearAlerta($cliente, trim($texto));

Espero que lo disfruteis.

515 Comments

  1. mp3juices dice:

    I was pretty pleased to find this web site. I need to to thank you for ones time due to this fantastic read!! I definitely enjoyed every part of it and I have you saved to fav to check out new things on your web site.

  2. This blog was… how do I say it? Relevant!! Finally I’ve found something that helped me. Appreciate it.

  3. I used to be able to find good information from your content.

  4. situs porno dice:

    I used to be able to find good info from your blog posts.

  5. Way cool! Some very valid points! I appreciate you writing this post plus the rest of the site is very good.

  6. situs porno dice:

    Greetings! Very helpful advice in this particular article! It’s the little changes that make the greatest changes. Thanks for sharing!

  7. That is a very good tip particularly to those new to
    the blogosphere. Short but very accurate info… Appreciate your sharing this
    one. A must read article!

  8. Slot demo dice:

    bookmarked!!, I really like your website.

  9. Hxcvlc dice:

    atenolol over the counter – atenolol 100mg over the counter coreg pill

  10. Tlupwn dice:

    calan 120mg for sale – cheap diltiazem 180mg tenoretic without prescription

  11. Ybqkfa dice:

    atorvastatin medication – buy nebivolol online how to get bystolic without a prescription

  12. Hvetkr dice:

    oral lasuna – cheap lasuna pill buy generic himcolin

  13. Aixfrg dice:

    gasex order online – gasex order purchase diabecon pill

  14. Myenuo dice:

    buy noroxin cheap – confido over the counter confido canada

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *