include_path = “/var/www/php-example/zendgdata/library:.:/usr/share/php5/”
php-cli - это интерпретатор php, запускаемый из shell. Он бывает очень полезным, если надо проверить ошибки в своем скрипте на пыхе, а на браузер переключаться лень. В ubuntu ставится из пакета php-cli.
php -f Calendar.php
Usage: php Calendar.php <action> [<username>] [<password>] [<arg1> <arg2> ...] Possible action values include: outputCalendar outputCalendarMagicCookie outputCalendarByDateRange outputCalendarByFullTextQuery outputCalendarList updateEvent deleteEventById deleteEventByUrl createEvent createQuickAddEvent createWebContentEvent createRecurringEvent setReminder addExtendedProperty
Usage: php Calendar.php createEvent <username> <password> <title> <description> <where> <startDate> <startTime> <endDate> <endTime> <tzOffset> EXAMPLE: php Calendar.php createEvent <username> <password> 'Tennis with Beth' 'Meet for a quick lesson' 'On the courts' '2008-01-01' '10:00' '2008-01-01' '11:00' '-08'
Собственно, всё скатано прямо из примеров. Сначала мы подключаемся, а затем создаем событие. Результат - новая запись в гугл-календаре!
<?php /** * Returns a HTTP client object with the appropriate headers for communicating * with Google using the ClientLogin credentials supplied. * * @param string $user The username, in e-mail address format, to authenticate * @param string $pass The password for the user specified * @return Zend_Http_Client */ require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata_AuthSub'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_HttpClient'); Zend_Loader::loadClass('Zend_Gdata_Calendar'); Zend_Loader::loadClass('Zend_Gdata_Calendar_EventEntry'); function getClientLoginHttpClient($user, $pass) { $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); return $client; } function createEvent ($client, $title = 'Tennis with Beth', $desc='Meet for a quick lesson', $where = 'On the courts', $startDate = '2008-01-20', $startTime = '10:00', $endDate = '2008-01-20', $endTime = '11:00', $tzOffset = '-08') { $gc = new Zend_Gdata_Calendar($client); $newEntry = $gc->newEventEntry(); $newEntry->title = $gc->newTitle(trim($title)); $newEntry->where = array($gc->newWhere($where)); $newEntry->content = $gc->newContent($desc); $newEntry->content->type = 'text'; $when = $gc->newWhen(); $when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00"; $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00"; $newEntry->when = array($when); $createdEntry = $gc->insertEvent($newEntry); return $createdEntry->id->text; } $authClient = getClientLoginHttpClient("wtf.with.calendar", "q1w2e3r4"); createEvent($authClient, 'my first event' , 'event description', 'nowhere', '2010-03-07', '02:00', '2010-03-07', '05:00', '-08'); ?>