0

I am trying to get the Contacts List through the Google Contacts API in my C# application.

Following is the code i am using to pull the Google Contacts, but not sure on parsing the Response:

        OAuthGContacts _google = new OAuthGContacts();
        if (Request["code"] == null)
        {
            Response.Redirect(_google.AuthorizationLinkGet());

        }
        else
        {
              //Get the access token and secret.
            _google.AccessTokenGet(Request["code"]);

            if (_google.Token.Length > 0)
            {
             string   _contactResponse = _google.WebRequest(OAuthGContacts.Method.GET, "https://www.google.com/m8/feeds/contacts/default/full?access_token=" + _google.Token, string.Empty);
             XmlReader reader = XmlReader.Create(new StringReader(_contactResponse ));
             SyndicationFeed feed = SyndicationFeed.Load(reader);
             reader.Close();
            }
        }

Please suggest on how to parse the Response to pull the Google Contacts.

rahul sachin
  • 51
  • 1
  • 4

1 Answers1

1

You don't need to parse any XML response to get a Contact List in a C# application. Google's Data API provides functionality to do that. Here is an .NET example. If you see the Protocol, then simply click to the .NET tab and you will see the following code

public static void PrintAllContacts(ContactsRequest cr)
{
  Feed<Contact> f = cr.GetContacts();
  foreach (Contact entry in f.Entries)
  ....
megabyte1024
  • 8,482
  • 4
  • 30
  • 44