Link to home
Create AccountLog in
Avatar of Craig Lambie
Craig LambieFlag for Australia

asked on

Get Extended Property from Google Contact using .Net Library

Hi Experts,

I am using this code to retrieve a list of contacts from Google Contacts
 public Feed<Contact> GetContacts()
        {
            //Provide Login Information
            RequestSettings rsLoginInfo = new RequestSettings("", Constants.GoogleAc.Username, Constants.GoogleAc.Password);
            rsLoginInfo.AutoPaging = true;

            // Fetch contacts and dislay them in ListBox
            cr = new ContactsRequest(rsLoginInfo);
            Feed<Contact> feedContacts = cr.GetContacts();

            return feedContacts;

        } //GetContacts

Open in new window


And I can successfully look up a lot of info, but I have created a custom field in my address book, and want to retrieve it.  I can't work out how to access the Extended Properties?
Any ideas?
foreach (Contact ct in cts.Entries)
            {
                ContactDetails Ctct = new ContactDetails();
                Ctct.FirstName = ct.Name.GivenName;
                Ctct.LastName = ct.Name.FamilyName;
                Ctct.Email = ct.PrimaryEmail.Value;
                Ctct.Mobile = ct.PrimaryPhonenumber.Value;
                Ctct.TwitterName = ct.ExtendedProperties ***????
}

Open in new window

Avatar of Jan Janßen
Jan Janßen
Flag of Germany image

I am not sure about .Net but in general it should look like this:

<entry gd:etag='"Q3k4cTVSLyp7ImA9WxRXFkwJRAA."'>
  <id>http://www.google.com/m8/feeds/contacts/liz%40gmail.com/base/8411573</id>
  <updated>2008-02-28T18:47:02.303Z</updated>
  <category scheme='http://schemas.google.com/g/2005#kind'
    term='http://schemas.google.com/contact/2008#contact' />
  <title>Jo</title>
  <content type='text'>Notes</content>
  <link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*'
    href='https://www.google.com/m8/feeds/photos/media/liz%40gmail.com/8411573' />
  <link rel='self' type='application/atom+xml'
    href='https://www.google.com/m8/feeds/contacts/liz%40gmail.com/full/8411573' />
  <link rel='edit' type='application/atom+xml'
    href='https://www.google.com/m8/feeds/contacts/liz%40gmail.com/full/8411573' />
  <gd:phoneNumber rel='http://schemas.google.com/g/2005#other'
    primary='true'>456-123-2133</gd:phoneNumber>
  <gd:extendedProperty name='my-service-id' value='1234567890' />
  <gd:extendedProperty name='my-second-service'>
    <value-element>text value</value-element>
  </gd:extendedProperty>
</entry>

Open in new window


http://code.google.com/apis/contacts/docs/2.0/reference.html#ProjectionsAndExtended


Now I would think the Google address book API is similar to the Google calendar API
EventEntry myEntry = new EventEntry();

ExtendedProperty property = new ExtendedProperty();
property.Name = "http://www.example.com/schemas/2005#mycal.id";
property.Value = "1234";

entry.ExtensionElements.Add(property);

Open in new window

http://code.google.com/apis/calendar/data/2.0/developers_guide_dotnet.html#ExtendedProps

Therefore it would be
ct.ExtendedProperty.name.value

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Craig Lambie
Craig Lambie
Flag of Australia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Craig Lambie

ASKER

Is the right answer.