Zend Gdata 日历事件更新不发送电子邮件通知

发布于 2024-11-23 18:41:56 字数 1247 浏览 5 评论 0原文

尽管以下代码片段确实成功地将其他访客添加到 Google 日历活动,但它并未向他们发送活动的电子邮件通知。有人可以告诉我是否也可以向新客人发送电子邮件?

     $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name for calendar
 $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);

function sendInvite($eventId, $email)
{
    $gdataCal = new Zend_Gdata_Calendar($client);
    if($eventOld = $this->getEvent($eventId))
    {

        $who = $gdataCal->newwho();
        $who->setEmail($email);

        $eventOld->setWho(array_merge(array($who), $eventOld->getWho())); 

        try
        {
            $eventOld->save();
        } catch(Zend_Gdata_App_Exception $e)
        {
            return false;
        }

        return true;
    } else
        return false;
} 

function getEvent($eventId)
{
    $gdataCal = new Zend_Gdata_Calendar($client);
    $query = $gdataCal->newEventQuery();
    $query->setUser('default');
    $query->setVisibility('private');
    $query->setProjection('full');
    $query->setEvent($eventId);
    try
    {
        $eventEntry = $gdataCal->getCalendarEventEntry($query);
        return $eventEntry;
    } catch(Zend_Gdata_App_Exception $e)
    {
        return null;
    }
}

Although the following code snippet does successfully add additional guests to a google calendar event, it is not sending them email notifications of the event. Can someone tell me if it's possible to also send an email to the new guests?

     $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name for calendar
 $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);

function sendInvite($eventId, $email)
{
    $gdataCal = new Zend_Gdata_Calendar($client);
    if($eventOld = $this->getEvent($eventId))
    {

        $who = $gdataCal->newwho();
        $who->setEmail($email);

        $eventOld->setWho(array_merge(array($who), $eventOld->getWho())); 

        try
        {
            $eventOld->save();
        } catch(Zend_Gdata_App_Exception $e)
        {
            return false;
        }

        return true;
    } else
        return false;
} 

function getEvent($eventId)
{
    $gdataCal = new Zend_Gdata_Calendar($client);
    $query = $gdataCal->newEventQuery();
    $query->setUser('default');
    $query->setVisibility('private');
    $query->setProjection('full');
    $query->setEvent($eventId);
    try
    {
        $eventEntry = $gdataCal->getCalendarEventEntry($query);
        return $eventEntry;
    } catch(Zend_Gdata_App_Exception $e)
    {
        return null;
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

虚拟世界 2024-11-30 18:41:56

终于想通了。

public function sendInvite($eventId, $email)
{
    $gdataCal = new Zend_Gdata_Calendar($this->client);

    if($eventOld = $this->getEvent($eventId))
    {
        $SendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); 
        $SendEventNotifications->setValue(true); 
        $eventOld->SendEventNotifications = $SendEventNotifications;
        $who = $gdataCal->newwho();
        $who->setEmail($email);

        $eventOld->setWho(array_merge(array($who), $eventOld->getWho())); 

        try
        {
            $eventOld->save();
        } catch(Zend_Gdata_App_Exception $e)
        {
            return false;
        }

        return true;
    } else
        return false;
} 

Finally figured it out.

public function sendInvite($eventId, $email)
{
    $gdataCal = new Zend_Gdata_Calendar($this->client);

    if($eventOld = $this->getEvent($eventId))
    {
        $SendEventNotifications = new Zend_Gdata_Calendar_Extension_SendEventNotifications(); 
        $SendEventNotifications->setValue(true); 
        $eventOld->SendEventNotifications = $SendEventNotifications;
        $who = $gdataCal->newwho();
        $who->setEmail($email);

        $eventOld->setWho(array_merge(array($who), $eventOld->getWho())); 

        try
        {
            $eventOld->save();
        } catch(Zend_Gdata_App_Exception $e)
        {
            return false;
        }

        return true;
    } else
        return false;
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文