【问题标题】:How do I grab the contact for a user in my Google Apps domain?如何获取我的 Google Apps 域中用户的联系人?
【发布时间】:2013-04-02 22:43:36
【问题描述】:

这是设置代码(我使用的是 Powershell,因为它通常很方便)

$a1= Add-Type -Path "D:\Google2.1\Google.GData.Client.dll" -passthru
$a2= Add-Type -Path "D:\Google2.1\Google.GData.Apps.dll" -passthru
$a3= Add-Type -Path "D:\Google2.1\Google.GData.Contacts.dll" -passthru
$a4= Add-Type -Path "D:\Google2.1\Google.GData.Extensions.dll" -passthru

$reqSet = New-Object Google.GData.Client.RequestSettings("testApp", $config.admin, $config.password)
$reqSet.AutoPaging = $true

$contReq = New-Object Google.Contacts.ContactsRequest($reqSet)

所以,现在我尝试检索联系人:

$contReq.GetContacts()

这行得通...并给了我我的联系人(作为域超级管理员)。酷

$contReq.GetContacts("arbitraryuser@mydomain.com")

这给了我一个类似的错误

 format-default : Execution of request failed: https://www.google.com/m8/feeds/contacts/arbitraryuser@mydomain.com/full

我确实获得了一个附加的 GDataLoggingRequestFactory 因子来记录请求,只是指出了一个 401 错误,没有详细信息。

【问题讨论】:

标签: google-profiles-api


【解决方案1】:

问题开始老了,但因为我正在从事这样的项目......

我正在使用最新的.NET client library distribution

这是一个有效的 PS 代码示例:

$a1 = Add-Type -Path "C:\Program Files (x86)\Google\Google Data API SDK\Redist\Google.GData.Client.dll" -passthru

$a2 = Add-Type -Path "C:\Program Files (x86)\Google\Google Data API SDK\Redist\Google.GData.Contacts.dll" -passthru

$a3 = Add-Type -Path "C:\Program Files (x86)\Google\Google Data API SDK\Redist\Google.GData.Extensions.dll" -passthru

$Settings = New-Object Google.GData.Client.RequestSettings( "MyApp", "mybelovedtrashbox@gmail.com", "mypassword" )

$reqSet = New-Object Google.Contacts.ContactsRequest( $Settings )

$Contacts = $reqSet.GetContacts()
#loop version
foreach( $Contact in $Contacts.Entries ){
    $Contact.PrimaryEmail.Address
}

#selection version
$user = $Contacts.Entries |? { $_.PrimaryEmail.Address -eq "john.doe@gmail.com" }
$user.Title

希望这会有所帮助...

我正在编写允许从 Outlook 联系人更新我的 gmail 联系人的代码,如果您需要详细信息,请告诉我... :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-09
    • 1970-01-01
    • 1970-01-01
    • 2013-08-19
    • 2014-02-23
    • 1970-01-01
    相关资源
    最近更新 更多