0
我在谷歌創建共享聯繫人,它創建聯繫人,但我看不到谷歌聯繫人目錄中的聯繫人。谷歌共享聯繫人 - 沒有出現在目錄
我一直在尋求答案,並找到可能this最接近..但我似乎無法得到它的權利......
下面是一些代碼:
string s = "https://www.google.com/m8/feeds";
string targetUri = @"https://www.google.com/m8/feeds/contacts/mycompany.com/full";
string serviceAccountEmail = "[email protected]account.com";
string serviceClientId = "123456789012-xxxx1x1xx11x1xxxxxxx11xxxx1xxx11.apps.googleusercontent.com";
X509Certificate2 certificate = new X509Certificate2(@"C:\All\mygcertificate-1xx1xxx1xx11.p12", "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[]
{
"http://www.google.com/m8/feeds/contacts/"
},
User = "[email protected]"
}.FromCertificate(certificate));
string AuthenticationToken1 = string.Empty;
if (credential.RequestAccessTokenAsync(CancellationToken.None).Result)
{
AuthenticationToken1 = credential.Token.AccessToken;
}
Service service = new Service(s, serviceClientId);
GAuthSubRequestFactory factory = new GAuthSubRequestFactory(s, serviceClientId);
factory.Token = AuthenticationToken1;
service.RequestFactory = factory;
Contact ct = new Contact();
ct.Name = new Google.GData.Extensions.Name() { GivenName = "Ron", FamilyName = "Swanson", FullName = "Ron Swanson" };
ct.Emails.Add(new Google.GData.Extensions.EMail("[email protected]", @"http://schemas.google.com/g/2005#work") { Primary = true });
ct.Phonenumbers.Add(new Google.GData.Extensions.PhoneNumber("2345555522") { Rel = @"http://schemas.google.com/g/2005#work", Primary = true});
AtomCategory atc = new AtomCategory();
atc.Term = @"http://schemas.google.com/contact/2008#contact";
atc.Scheme = @"http://schemas.google.com/g/2005#kind";
ct.Categories.Add(atc);
var atomentrytoinsert = ct.AtomEntry;
var result = service.Insert(new Uri(targetUri), atomentrytoinsert);
//Stream getresult = service.Query(new Uri(targetUri)); //this read actually gets the records i inserted...
如果我跑,去年我可以看到我創建的條目......但當我去google聯繫人並點擊目錄時 - 他們不在那裏。當我編寫電子郵件時,也沒有自動完成...我是否在某處丟失了一個屬性。
我已經在24小時內離開了作品(我在星期五創作了它們)。
將不勝感激任何輸入。