El TecnoBaúl de Kiquenet

Kiquenet boring stories

Posts Tagged ‘nuget’

Google Calendar API

Posted by kiquenet en 26 diciembre 2014

Nuget: https://www.nuget.org/packages?q=google+calendar

Install-Package Google.GData.Calendar 
Install-Package Google.Apis.Calendar.v3

http://support.google.com/mail/bin/answer.py?hl=it&answer=1173270 to get  Application-specific password

http://googleappsupdates.blogspot.com.es/2014/06/calendar-gdata-api-google-calendar.html

Back in November 2011, we announced the deprecation of the Calendar GData API (v1, v2) when the APIv3 was made available. We’ll now be shutting down these older versions on November 17, 2014.
Any service dependent on the Calendar GData API (v1, v2), such as the Google Calendar Connectors (GCC), will no longer work as intended. GCC users should update to use Calendar Interop or their own custom built connectors that sync with v3 of the API.

Migration guide:

https://developers.google.com/google-apps/calendar/migration

http://www.programmableweb.com/news/google-calendar-api-v1-and-v2-to-shut-down-nov-17/2014/10/27

Code

NOT YET

    

Source:
http://dotnetoday.blogspot.com.es/search/label/Google%20API%20-%20Calendar

Anuncios

Posted in .NET, Google | Etiquetado: , | Leave a Comment »

Google Contacts API

Posted by kiquenet en 26 diciembre 2014

Nuget: https://www.nuget.org/packages?q=google+contacts

Install-Package Google.GData.Contacts (version 2.2)
Install-Package Google.GData.Client (version 2.2 stable)

http://support.google.com/mail/bin/answer.py?hl=it&answer=1173270 to get  Application-specific password

Code

      [TestMethod]
      public void Obtener_contactos_de_google()
      {
          // login
          var Service = new ContactsService("google-contacts");
          Service.setUserCredentials("xxxx@gmail.com", "xxxxx");
          Service.QueryClientLoginToken();

          var Contacts = new List<string[]>();

          var query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
          query.StartIndex = 1;

          ContactsFeed feed = Service.Query(query);

          var total = 0;
          while (feed != null && feed.Entries.Count > 0)
          {
              total += feed.Entries.Count;
              foreach (ContactEntry entry in feed.Entries)
              {
                  // This Example gets the phone numbers but we can obtain the info we want/need about the contact
                  if (entry.Phonenumbers.Count > 0)
                  {
                      string phoneNumbers = "";
                      // get all phone numbers
                      for (int a = 0; a < entry.Phonenumbers.Count; a++)
                      {
                          phoneNumbers += entry.Phonenumbers[a].Value + "; ";
                      }

                      int x = phoneNumbers.LastIndexOf(";");
                      phoneNumbers = phoneNumbers.Substring(0, phoneNumbers.LastIndexOf(";"));

                      // in the array "item" there are: fullname(name and surname), phone number1;phonenumber2;…., contact url for edit
                      string[] item = { entry.Name.FullName, phoneNumbers, entry.Id.AbsoluteUri };
                      Contacts.Add(item);
                  }
              }

              // move to next page until end
              if (feed.NextChunk != null)
              {
                  query.Uri = new Uri(feed.NextChunk);
                  feed = Service.Query(query) as ContactsFeed;
              }
              else
                  feed = null;
          }

          // sorting the list for full name
          Contacts.Sort(delegate(string[] item1, string[] item2)
          {
              return item1[0].CompareTo(item2[0]);
          });

          Assert.AreNotEqual(0, Contacts.Count);
          Assert.IsTrue(total > 900);

      }

Source:
http://dotnetoday.blogspot.com.es/2012/10/c-google-api-getting-google-contacts.html?showComment=1382645543065

Posted in .NET, Google | Etiquetado: , | Leave a Comment »