0
我有與Gmail帳戶相關的應用程序。我想添加我的本地數據庫聯繫人到Gmail帳戶。我已經提到這個鏈接:how to create google contact? 這可能嗎?請建議我實現這一點。如何將我的本地聯繫人添加到Gmail帳戶?
我有與Gmail帳戶相關的應用程序。我想添加我的本地數據庫聯繫人到Gmail帳戶。我已經提到這個鏈接:how to create google contact? 這可能嗎?請建議我實現這一點。如何將我的本地聯繫人添加到Gmail帳戶?
不能與gmail-api
創建聯繫人,但Contacts API: Creating Contacts會做你在找什麼:
public static Contact CreateContact(ContactsRequest cr)
{
Contact newEntry = new Contact();
// Set the contact's name.
newEntry.Name = new Name()
{
FullName = "Elizabeth Bennet",
GivenName = "Elizabeth",
FamilyName = "Bennet",
};
newEntry.Content = "Notes";
// Set the contact's e-mail addresses.
newEntry.Emails.Add(new EMail()
{
Primary = true,
Rel = ContactsRelationships.IsHome,
Address = "[email protected]"
});
newEntry.Emails.Add(new EMail()
{
Rel = ContactsRelationships.IsWork,
Address = "[email protected]"
});
// Set the contact's phone numbers.
newEntry.Phonenumbers.Add(new PhoneNumber()
{
Primary = true,
Rel = ContactsRelationships.IsWork,
Value = "(206)555-1212",
});
newEntry.Phonenumbers.Add(new PhoneNumber()
{
Rel = ContactsRelationships.IsHome,
Value = "(206)555-1213",
});
// Set the contact's IM information.
newEntry.IMs.Add(new IMAddress()
{
Primary = true,
Rel = ContactsRelationships.IsHome,
Protocol = ContactsProtocols.IsGoogleTalk,
});
// Set the contact's postal address.
newEntry.PostalAddresses.Add(new StructuredPostalAddress()
{
Rel = ContactsRelationships.IsWork,
Primary = true,
Street = "1600 Amphitheatre Pkwy",
City ="Mountain View",
Region = "CA",
Postcode = "94043",
Country = "United States",
FormattedAddress = "1600 Amphitheatre Pkwy Mountain View",
});
// Insert the contact.
Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));
Contact createdEntry = cr.Insert(feedUri, newEntry);
Console.WriteLine("Contact's ID: " + createdEntry.Id)
return createdEntry;
}
@Tholle謝謝。這會在Gmail帳戶中創建新的聯繫人,但它不會顯示在聯繫人列表中。我必須從搜索中打開「伊麗莎白貝內特」,然後我必須編輯 - 保存聯繫人以將其保存在聯繫人列表中。 –