2014-02-14 78 views
3

我已經到了這裏與我的腳本,它只是應該爲特定時間段(即我在日曆中看到)檢索特定日曆的條目。如何通過Google Calendar API檢索相關日曆活動?

#Powershell 

ls (join-path $Script:scriptpath .\GDataCmdLet-master\Binaries\*.dll) | % { 
    [System.Reflection.Assembly]::LoadFile($_) 
} 

$service=new-object Google.GData.Calendar.CalendarService('Test') 
$cred = New-Object Google.GData.Client.GDataCredentials('[email protected]', '1234') 

$service.credentials=$cred 

$eventquery=new-object Google.GData.Calendar.EventQuery 
$eventquery.uri='http://www.google.com/calendar/feeds/[email protected]/private/full' 
$eventquery.StartDate = (Get-Date -Date '2014-02-10') 
$eventquery.EndDate = (get-date -date '2014-02-20') 

$eventfeed=$service.query($eventquery) 

的DLL文件,我從https://github.com/robertj/GDataCmdLet

所有從日曆事件實際上已經被移除(即我沒有看到任何的webinterface)得到的,但我一直在得到這些結果。

問題,回答任何一個就足夠了:

  1. 是否有結果的標誌,以區別非刪除事件刪除?

  2. 有沒有辦法只檢索未刪除的事件呢? (查詢中的參數?showhidden = false沒有幫助)

謝謝!

Sandro

回答

0

解決了!下面似乎工作,不知道確切原因艱難

ls (join-path $Script:scriptpath .\GDataCmdLet-master\Binaries\*.dll) | % { 
    [System.Reflection.Assembly]::LoadFile($_) 
} 

$service=new-object Google.GData.Calendar.CalendarService('Test') 
$cred = New-Object Google.GData.Client.GDataCredentials('[email protected]', '1234') 

$service.credentials=$cred 

$eventquery=new-object Google.GData.Calendar.EventQuery 
$eventquery.uri='http://www.google.com/calendar/feeds/[email protected]/private/basic' 

#don't use StartDate and EndDate this way 
#they just didn't have the expected effect 
$eventquery.StartTime = (Get-Date -Date '2014-02-10') 
$eventquery.EndTime = (get-date -date '2014-02-30') 

#that does the trick to get the actual occurences, not just the events 
#and it also removed the non-deleted ones 
$eventquery.SingleEvents = $true 

$eventfeed=$service.query($eventquery) 

現在我不知道從哪裏得到來自OCCURENCES的開始和結束時間,但這是另外一個問題來回答......

相關問題