2013-04-02 62 views
2

下面是设置代码(我使用PowerShell的,因为它通常是方便)如何获取我的Google Apps域中用户的联系人?

$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("[email protected]") 

这让我像

format-default : Execution of request failed: https://www.google.com/m8/feeds/contacts/[email protected]/full 

我没有得到附加记录的请求以及一个GDataLoggingRequestFactory因素,而只是表明一个401错误,没有细节的错误。

+0

你有没有试过@ site.com只是“任意用户”? –

+0

是的,我有。可悲的是,相同的结果 –

+0

顺便说一句,我试图模拟的代码是在https://code.google.com/p/google-api-dotnet-client/wiki/OAuth2#Service_Accounts –

回答

0

问题开始老了,但因为我工作的这样一个项目?

我使用的是最新的.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", "[email protected]", "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 "[email protected]" } 
$user.Title 

希望这有助于...

我工作的代码,将允许从Outlook联系人中更新我的Gmail联系人,让我知道如果你需要尾巴...... :)

相关问题