PHPのGoogleカレンダーでのSMS通知+イベントログ

インスピレーション: 自動化の奇跡、または本物のオタクがSMSを送信する方法

人々がそのような洗練をすれば、それは多くを意味します。



数時間で、Googleカレンダーにイベントを追加するクラスが開発されました。 また、すでにGoogleのカレンダーからSMSが送信されます。



使用するには、カレンダーを正しく構成する必要があります(このために別のアカウントを作成する価値があります)。

1.カレンダーのタイムゾーンをサーバーと同じに設定します。

2. SMS通知を設定します(設定->モバイルデバイスの設定)

3.カレンダーのデフォルト通知を設定します(カレンダー設定-通知)

デフォルトでは、イベントの1分前にSMSで通知するように設定されています。 高度なメール通知を追加できます。

それだけです カレンダーを準備しました。



スクリプトが機能するためには、ZendFrameworkの一部が必要です。

gdataクラスセット: framework.zend.com/download/gdata



そして、クラスと使用例を含むスクリプトコード:



<?

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' );



class GCAlerter

{

public $gcCalendar;

public $gcTimeCorrect;



public function __construct($user, $pass, $tc)

{

$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, "cl" );

$ this ->gcCalendar = new Zend_Gdata_Calendar($client);

$ this ->gcTimeCorrect = $tc;

}



public function Alert($text)

{

$quickAddText = "$text " .date( "h:i" ,time() + $ this ->gcTimeCorrect);

$ event = $ this ->gcCalendar->newEventEntry();

$ event ->content = $ this ->gcCalendar->newContent($quickAddText);

$ event ->quickAdd = $ this ->gcCalendar->newQuickAdd( 'true' );

$newEvent = $ this ->gcCalendar->insertEvent($ event );

return $newEvent->id->text;

}

}



$user = "mycal@gmail.com" ;

$pass = 'mypass' ;

$timecorr = 2*60; // 2*60 = 2 min, 10*60 = 10min



$gcAlerter = new GCAlerter($user, $pass, $timecorr);

$gcAlerter->Alert( "OMG I`m die!!!" );

?>




* This source code was highlighted with Source Code Highlighter
.








$ timecorr-時間調整変数。

サーバー時間とGoogle時間は、サーバー時間が正しくないために異なる場合があります。 これを常に修正できるとは限りません。

実際、このパラメーターを使用して、通知がイベントの1分以内に到着するように必要な時間を調整します。



All Articles