使用Google日历api更新时区

时间:2015-02-28 11:53:38

标签: google-api-php-client

我正在尝试更新Google事件时区,但无法找到更新时区的任何方法是,有获取时区的方法

   $calendar = $googleCalendarUsage->calendars->get(self::CALENDAR_NAME);
   echo $calendar->getTimeZone();

通过上面的代码,我得到了事件时区,但我找不到任何更新时区的方法。

下面是我的代码所有事情都是正确的,但无法更新事件的时区。

public function updateGoogleEvents($selectedEventValue,$selectGuestValue,$selectUserEmailAddress,$selectUserIdentityDetails,$updateGoogleTimeZone) {
    $smartyTemplatePath       =dirname(__DIR__);
    $smartyObject             =new ConnectSmarty($smartyTemplatePath.DS.self::SMARTY_MODEL_FOLDER.DS.self::SMARTY_TEMPLATES_FOLDER);
    include_once Mage::getBaseDir(self::LIBRARY_PATH).self::CLIENT_API_FILE_PATH;
    include_once Mage::getBaseDir(self::LIBRARY_PATH).self::CALENDAR_FILE_PATH;
    $googleClient = new Google_Client();
    $googleClient->setApplicationName(self::GOOGLE_CALENDAR_MESSAGE);
    $googleClient->setClientId(parent::getApiKey(self::CONNECTOR_NAME));
    $googleClient->setClientSecret(parent::getApiSecretKey(self::CONNECTOR_NAME));
    $googleClient->setRedirectUri($basePath.self::INDEX_FILE_PATH);
    $googleClient->setDeveloperKey(self::SERVICE_ACCOUNT);
    $googleClient->setUseObjects(true);
    $googleCalendar=new Google_CalendarService($googleClient);
    $getDatabaseConnection=Mage::getSingleton(self::CORE_RESOURCE)->getConnection(self::CORE_WRITE);
    $selectOauthToken=$getDatabaseConnection->prepare(self::GET_ACCESS_TOKEN);
    $selectOauthToken->bindParam(self::SELECT_OUTH_TOKEN_USER_EMAIL, $selectUserEmailAddress);
    $selectOauthToken->bindParam(self::OUTH_TOKEN_IDENTITY_DETAILS, $selectUserIdentityDetails);
    $userIdentity=Mage::getModel(self::GET_USER_PROFILE_MODEL)->SetCustomerDetail($selectUserEmailAddress);
    $selectOauthToken->execute();
    $oauthToken=$selectOauthToken->fetch();
    $tokenData=$oauthToken[self::OUTH_TOKEN];
    $googleClient->setAccessToken($tokenData);
    if ($googleClient->getAccessToken())
    {
        if(!class_exists(self::CLASS_EVENTS))
        {
            $includeApplicationFiles=Mage::getBaseDir(self::LIBRARY_PATH);
            foreach (glob($includeApplicationFiles.self::INCLUDE_ALL_FILES) as $retrieveFiles)
            {
                include $retrieveFiles;
            }
            $allCalendarEvents = $googleCalendar->events->listEvents(self::CALENDAR_NAME);
            $calendar = $googleCalendarUsage->calendars->get(self::CALENDAR_NAME);

            //echo $calendar->getTimeZone();die;//by doing this i am getting Asia/Calcutta as output
            foreach ($allCalendarEvents->getItems() as $getSingleEvent) {
                if($selectedEventValue==$getSingleEvent->summary)
                {
                    $getSingleEvent->setSummary($selectedEventValue);
                    $addEventGuests = new Google_EventAttendee();
                    $addEventGuests->setEmail($selectGuestValue);
                    $invitedGuests = array($addEventGuests);
                    $getSingleEvent->attendees = $invitedGuests;
                    $updatedEvent = $googleCalendar->events->update(self::CALENDAR_NAME, $getSingleEvent->getId(),$getSingleEvent);
                }
            }
        }
    }
}

setSummary,setEmail是将更新事件标题事件电子邮件地址的函数我想知道是否有更新时区的功能?类似......

setTimeZone("Asia/Calcutta") 不幸的是,我甚至尝试使用像setTimeZone这样的功能,但它没有定义,因此无法正常工作。

任何帮助将不胜感激,提前谢谢。

0 个答案:

没有答案