2011-03-15 49 views
2

我想用短信通知添加事件到我的日历。我成功添加了一个活动,但无法将通知添加到该活动中。使用谷歌日历API添加事件与短信通知

这里是我当前的代码:http://en.paidpaste.com/8Lnv4w

更多关于谷歌日历API信息:

Data API Developer's Guide: PHP

Integrate your PHP application with Google Calendar

更新:

好像API损坏或类似的东西,尝试了一切......

+0

颠簸允许吗? – 2011-03-15 16:05:02

+0

不是。如果您需要快速回复,请尝试在各种聊天频道中广告问题(请参阅页面顶部标题中的链接)或提供奖励(尽管我相信您必须等待一段时间能够做到这一点)。 – 2011-03-15 16:57:45

+0

您提供的链接是文档v1。也许你的Zend与实际的API不同步?您可能需要跟踪'newReminder'方法。另外,你的代码实际上是试图设置一个弹出式提醒,你需要使用'sms'而不是'alert'。 – 2011-03-15 17:01:12

回答

1

正确的代码:

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