我的脚本已经走到这一步了,它只是应该检索特定日历在特定时间段内的条目(即我在日历中看到的内容)。
#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('joe@gmail.com', '1234')
$service.credentials=$cred
$eventquery=new-object Google.GData.Calendar.EventQuery
$eventquery.uri='http://www.google.com/calendar/feeds/joe@gmail.com/private/full'
$eventquery.StartDate = (Get-Date -Date '2014-02-10')
$eventquery.EndDate = (get-date -date '2014-02-20')
$eventfeed=$service.query($eventquery)
我从 https://github.com/robertj/GDataCmdLet 得到的 DLL
日历中的所有事件实际上都已删除(即我在网络界面中看不到任何事件),但结果是我继续获取这些事件。
问题,回答其中一个就足够了:
结果中是否有标志,用于区分已删除事件和未删除事件?
有没有办法首先只检索未删除的事件? (查询中的参数 ?showhidden=false 没有帮助)
谢谢!
桑德罗
最佳答案
解决了!以下似乎有效,不确定到底为什么困难
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('joe@gmail.com', '1234')
$service.credentials=$cred
$eventquery=new-object Google.GData.Calendar.EventQuery
$eventquery.uri='http://www.google.com/calendar/feeds/joe@gmail.com/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)
现在我不知道从哪里得到事件的开始和结束时间,但这是另一个问题要回答...
关于powershell - 如何通过 Google Calendar API 检索相关日历事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21773637/