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.

18 Comments

  1. CeleneKet dice:

    Doctors rarely probe into the full set of psychiatric and physical symptoms of their patients which could indicate TBD buy finasteride

  2. Your blog post had me hooked from the first sentence.

  3. Cwgsoz dice:

    atorvastatin 20mg over the counter order atorvastatin 40mg buy cheap generic lipitor

  4. Dbwhaj dice:

    cipro 1000mg cost – buy keflex 500mg buy amoxiclav sale

  5. Imdmpc dice:

    buy cipro pills for sale – buy generic myambutol for sale how to get augmentin without a prescription

  6. Eowmss dice:

    purchase flagyl generic – how to buy amoxicillin azithromycin 500mg oral

  7. Qedszs dice:

    ciplox 500 mg for sale – brand erythromycin 500mg erythromycin canada

  8. Ymqjav dice:

    order generic valacyclovir – buy valacyclovir online cheap acyclovir generic

  9. Ghahbw dice:

    buy ivermectin stromectol – purchase suprax for sale buy sumycin 250mg pill

  10. Poughj dice:

    metronidazole over the counter – order cefaclor 250mg online buy zithromax 500mg sale

  11. e-commerce dice:

    Wow, wonderful weblog layout! How long have
    you been blogging for? you make blogging glance easy.

    The total glance of your site is great, as smartly as the
    content material! You can see similar here e-commerce

  12. Have you ever thought about including a
    little bit more than just your articles? I mean, what you say is
    fundamental and everything. Nevertheless think of if you added some great visuals or videos to give your posts more, «pop»!
    Your content is excellent but with images and clips, this blog could definitely be one
    of the very best in its niche. Wonderful blog! I saw similar here: Najlepszy sklep

  13. Jdrfpl dice:

    purchase ampicillin sale buy generic ampicillin purchase amoxil

  14. Nfhdqk dice:

    furosemide ca – buy captopril without prescription order capoten for sale

  15. sklep online dice:

    Hi there! Do you know if they make any plugins to assist with Search Engine Optimization? I’m trying
    to get my blog to rank for some targeted keywords but I’m not seeing very good success.
    If you know of any please share. Cheers!
    You can read similar text here: Najlepszy sklep

  16. It’s very interesting! If you need help, look here: ARA Agency

  17. Oyehbn dice:

    metformin 1000mg cost – order glucophage 1000mg pill buy lincocin pills for sale

  18. Fhcgsu dice:

    retrovir drug – order glycomet 500mg order zyloprim 100mg online cheap

Deja una respuesta

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