开发者

Zend Gdata Calendar Event Update Not Sending Email Notification

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 = $gdat开发者_开发百科aCal->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;
    }
}


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;
} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜