Here's what I have, sort of a paraphrase of what I have actually ......
In essences, the actual update is the same as just a plain contact, you
just have to add the phone numbers and such to the entry. Here's what
I've been using. For about three days of testing now :)
A function here called AdBkEntryValue() parses a value out of the return
set (called <entry>) from my source system, just know that it returns a
string (possibly with newlines in it) of something reasonable here or an
empty string if there's no value in the source.
// Create the contact entry that we will populate
ContactEntry newContact = new ContactEntry();
// Throw the display name into there. The assumption is
// that the display name is what the contact is known as.
newContact.Title.Text = AdBkEntryValue("cn", entry);
// Create the email property and add it. Set relationship
// to be IsOther for all addresses, since Mirapoint only
// has one kind of email per contact. And since it's the
// only address, set it to be the primary one.
EMail newEmail = new EMail(AdBkEntryValue("mail", entry));
newEmail.Primary = true;
newEmail.Rel = ContactsRelationships.IsOther;
newContact.Emails.Add(newEmail);
// if there's a postal address, add that, too. Relationship
// and primary is set like for the email address.
t = AdBkEntryValue("postaladdress", entry);
if (t != "")
{
PostalAddress newPostal = new PostalAddress();
// Also add in things like City, Province etc that Mirapoint
// splits out but Google throws into one big box.
t += "\r\n";
t += AdBkEntryValue("l", entry) + " "; // city
t += AdBkEntryValue("st", entry) + " "; // prov
t += AdBkEntryValue("postalcode", entry) + "\r\n"; // postal
t += AdBkEntryValue("c", entry); // countty
newPostal.Value = t;
newPostal.Primary = true;
newPostal.Rel = ContactsRelationships.IsOther;
newContact.PostalAddresses.Add(newPostal);
}
// Assorted stuff. Just text.
// Also throw in the anniversary and birthdates here.
t = AdBkEntryValue("description", entry);
// these next two return any date in there if needed
t += AdBkEntryDate("anniversary", entry);
t += AdBkEntryDate("birth", entry);
t += "\r\nWebsite: ";
t += AdBkEntryValue("homeurl", entry);
if (t != "")
{
newContact.Content.Content = t;
}
// Phone numbers, how they translate
// Mirapoint Name Primary true if Google Name
// -------------------------- --------------- -----------
// telephonenumber: primaryphone=0 Work
// homephone: primaryphone=1 Home
// mobile: primaryphone=2 Mobile
// pager: primaryphone=3 Pager
// facsimiletelephonenumber: primaryphone=4 Work Fax
// n/a Home Fax
// n/a Other
//
// "telephonenumber"/"Work", primaryphone=0
t = AdBkEntryValue("telephonenumber", entry);
if (t != "")
{
PhoneNumber p = new PhoneNumber(t);
p.Label = "Work";
p.Primary = (AdBkEntryValue("primaryphone", entry)=="0");
newContact.Phonenumbers.Add(p);
}
// "homephone"/"Home", primaryphone=1
t = AdBkEntryValue("homephone", entry);
if (t != "")
{
PhoneNumber p = new PhoneNumber(t);
p.Label = "Home";
p.Primary = (AdBkEntryValue("primaryphone", entry)=="1");
newContact.Phonenumbers.Add(p);
}
// "mobile"/"Mobile", primaryphone=2
t = AdBkEntryValue("mobile", entry);
if (t != "")
{
PhoneNumber p = new PhoneNumber(t);
p.Label = "Mobile";
p.Primary = (AdBkEntryValue("primaryphone", entry)=="2");
newContact.Phonenumbers.Add(p);
}
// "pager"/"Pager", primaryphone=3
t = AdBkEntryValue("pager", entry);
if (t != "")
{
PhoneNumber p = new PhoneNumber(t);
p.Label = "Pager";
p.Primary = (AdBkEntryValue("primaryphone", entry)=="3");
newContact.Phonenumbers.Add(p);
}
// the "facsimiletelephonenumber"/"Work Fax", primaryphone=4
t = AdBkEntryValue("facsimiletelephonenumber", entry);
if (t != "")
{
PhoneNumber p = new PhoneNumber(t);
p.Label = "Work Fax";
p.Primary = (AdBkEntryValue("primaryphone", entry)=="4");
newContact.Phonenumbers.Add(p);
}
// Fill in the Organization and Job Title fields, if there.
// First see if the two together have anything, if yes
// then build the entry and add it.
t = AdBkEntryValue("o", entry) + AdBkEntryValue("title", entry);
if (t != "")
{
Organization newOrganization = new Organization();
t = AdBkEntryValue("o", entry);
if (t != "")
{
newOrganization.Name = t;
}
t = AdBkEntryValue("title", entry);
if (t != "")
{
newOrganization.Title = t;
}
// No idea what this line does. But it doesn't
// break and it's in the sample code.
newOrganization.Rel =
"http://schemas.google.com/g/2005#other";
newContact.Organizations.Add(newOrganization);
}
// Add the contact to the group. Actually, we add the group
// to the contact, but the effect is the same. First, get the
// category name by grabbing the number and then translating.
// And we don't do the "Unfiled" group, because it's Unfiled.
t = AdBkEntryValue("category", entry).ToUpper();
// if the length returned is pretty big, assume that the
// contact group is specified by name, otherwise, translate
// the numericreference Mirapoint uses to the name the user has
if ( t.Length < 6 ) // unlikely anyone has > 99999 groups
{
t = CategoryNumberToName(MiraGroupList, t).ToUpper();
}
if (t != "UNFILED")
{
// go though the groups list in google and see if
// we get a match by name, case-insensitive
for (int i = 0; i < GoogGroupList.Length; i++)
{
// if we have a match, add the group.
if (GoogGroupList[i].Title.Text.ToUpper() == t)
{
GroupMembership GrpMbr = new GroupMembership();
GrpMbr.HRef = GoogGroupList[i].Id.AbsoluteUri;
newContact.GroupMembership.Add(GrpMbr);
}
}
}
And then here, you just insert the contact with all the information
you've added to it into Google.
HTH.
--
Andre Roy -- If that don't fix it, then it's still broke.
Could you check it out?
http://allmybookings.com/googlecontactsinfo.php
You need to click on the top link
Then you grand access,
And then it goes to:
http://allmybookings.com/viewcontacts.php?token=CK3iteHqChDZ_52o______8B
But I get a white page,
What am I doing wrong? I used your new code, with my email
"seba...@gmail.com" and it's password.
Thanks
Sebastian