【问题标题】:Zend Gdata Calendar Event Update Not Sending Email NotificationZend Gdata 日历事件更新不发送电子邮件通知
【发布时间】:2012-01-27 18:31:52
【问题描述】:

虽然以下代码 sn-p 确实成功地将其他客人添加到 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;
    }
}

【问题讨论】:

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


    【解决方案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;
    } 
    

    【讨论】:

      猜你喜欢
      • 2014-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多