2

这是设置代码(我使用的是 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 错误,没有详细信息。

4

1 回答 1

0

Question starts to be old, but since i'm working on a project like this ...

I'm using the latest .NET client library distribution

Here's a sample of PS code that works :

$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

Hope this helps ...

I'm working on code that would allow to update my gmail contacts from outlook contacts, let me know if you need intails ... :)

于 2015-03-25T21:52:47.953 回答