首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Google Calendar API添加带有sms通知的事件

使用Google Calendar API添加带有sms通知的事件
EN

Stack Overflow用户
提问于 2011-03-15 16:12:11
回答 1查看 4.8K关注 0票数 2

我正在尝试使用短信通知将事件添加到我的日历中。我已成功添加事件,但无法向其中添加通知。

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

有关Google Calendar API的更多信息:

Data API Developer's Guide: PHP

Integrate your PHP application with Google Calendar

更新:

似乎API坏了或者类似的东西,尝试了所有的方法...

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-16 05:00:23

正确的代码:

代码语言:javascript
复制
<?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' );
?>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5309009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档