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

时间:2011-07-14 03:31:19

标签: zend-framework google-calendar-api gdata

虽然以下代码段确实成功地将其他来宾添加到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;
    }
}

1 个答案:

答案 0 :(得分: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;
}