powershell - 如何通过 Google Calendar API 检索相关日历事件?

标签 powershell google-calendar-api gdata-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('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

日历中的所有事件实际上都已删除(即我在网络界面中看不到任何事件),但结果是我继续获取这些事件。

问题,回答其中一个就足够了:

  1. 结果中是否有标志,用于区分已删除事件和未删除事件?

  2. 有没有办法首先只检索未删除的事件? (查询中的参数 ?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/

相关文章:

javascript - 使用 Blogger API 删除帖子

powershell - 如何将输出从命令重定向到变量?

google-calendar-api - 为什么显示名称未显示在日历事件参加者中?

azure - 如何使用 Powershell 在 Azure 漏洞评估中应用 "Approve as Baseline"

python - 使用 Calendar v3 api python 插入事件时出现 HttpError 401 "Login Required"

python - 如何检索日历事件参加者

youtube - YouTube javascript最受欢迎的视频API

ios - 异步加载和 UITableView 的 -reloadData

powershell - 使用 powershell 合并多个具有相同 header 的 csv 文件

azure - 用于管理 Azure Batch 应用程序版本保留的 PS 脚本