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

问题描述 投票:0回答:1

尽管以下代码片段确实成功地将其他访客添加到 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;
    }
}
php zend-framework google-calendar-api gdata
1个回答
1
投票

终于想通了。

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;
} 
© www.soinside.com 2019 - 2024. All rights reserved.