开发者

Use Google Calendar API to add event with sms-notification

I'm trying to add a event to my calendar with an sms-notification. I successfully added a event but I can't add the notification to it.

Here is my current code: http://en.paidpaste.com/8Lnv4w

More info about the Google Calendar API:

Data API Developer's Guide: PHP

Integrate your PHP application with Google Calendar

Update:

Seems 开发者_JAVA技巧like the API is broken or something like that, tried everything...


Correct code:

<?php
$path = 'GData';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');

$user = '*';
$pass = '*';
$service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name for calendar

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

////////////// Add event

function createEvent ($client, $title = 'Tennis with Beth',
$desc='Meet for a quick lesson', $where = 'On the courts',
$startDate = '2011-03-14', $startTime = '21:30',
$endDate = '2011-03-14', $endTime = '22:00', $tzOffset = '+01')
{
    $gdataCal = new Zend_Gdata_Calendar($client);
    $newEvent = $gdataCal->newEventEntry();

    $newEvent->title = $gdataCal->newTitle($title);
    $newEvent->where = array($gdataCal->newWhere($where));
    $newEvent->content = $gdataCal->newContent("$desc");
    $when = $gdataCal->newWhen();
    $when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00";
    $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00";
    // PÅMINNELSE!
    $reminder = $gdataCal->newReminder();
    $reminder->method = "sms";
    $reminder->minutes = "1";
    // LÄGG TILL I WHEN
    $when->reminders = array($reminder);
    // LÄGG TILL WHEN
    $newEvent->when = array($when);

    $createdEvent = $gdataCal->insertEvent($newEvent);
    return $createdEvent->id;
}

$eventId = createEvent($client, 'PartyPart', 'Kim Il Jong och jag', 'Mitt hus', '2011-03-15', '22:00', '2011-03-15', '22:05', '+01' );
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜