14

Question

Can anyone point me to a step-by-step example which explains how to get started with the Google Contacts API and shows a complete working demo?

Preferably in Java, but it can also be in C#, Python or Ruby.

Goal

All I want to do is to

  1. load an existing contact,
  2. add it to a group and
  3. save the contact back.

Problems

I am pretty much failing on every level.

  • Can't get the authentication to work
  • Can't find the libraries that contain the classes which are used in the code snippets I found on the Internet
  • Can't perform CRUD operations on an existing contact

Example

Here is some pseudo-code of what I am looking for.

import com.google.contacts.*

public class UpdateContactDemo {

   public static void main(String args[]) {
      GoogleContactsApi g = new GoogleContactsApi("username", "password");
      Contact c = g.get("Bob");
      c.addGroup("Friends");
      g.save(c);
   }
}

What I already did

Ok, I googled for tutorials, API examples and everything else I could think of -- and failed. I found a bunch of sources like these:

But non contained an end-to-end example for beginners.

Lernkurve
  • 20,203
  • 28
  • 86
  • 118
  • 1
    http://natashatherobot.com/2012/02/03/google-contacts-api-ruby-example/ – apneadiving Oct 12 '12 at 20:20
  • 1
    If I may make a recommendation... since you are having problems from beginning to end, break this question up into questions for each part? For example, get your issue with authentication handled first and then proceed with the following need. You're asking for a lot of code (or so I think) and it might turn off some people to helping out. – sunnyrjuneja Oct 12 '12 at 20:20
  • 1
    @SunnyJuneja: Thanks for the recommendation. However, all the snippets I've found so far were in fact bits and pieces tackling one aspect each, but didn't work when I tried to put them together into a demo. That's why I am asking for the "whole thing". – Lernkurve Oct 12 '12 at 20:25
  • @apneadiving: Thank you for the link. Had seen it before. Did you get it to run like that? – Lernkurve Oct 12 '12 at 20:39
  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it. – the Tin Man Nov 13 '19 at 01:44
  • This question is really old, and has had no activity. It's too broad, shows now effort, and needs to be closed. "[How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/q/261592/128421)" and "[How to handle “Explain how this ${code dump} works” questions](https://meta.stackoverflow.com/questions/253894/)" – the Tin Man Jan 24 '20 at 05:08

1 Answers1

1

My approach for C# was this one:

http://nanovazquez.com/2013/01/18/working-with-google-calendar-on-dotnet/

The code can be found on github: here

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  ...
  <appSettings>
    ...
    <!-- GoogleAPI credentials -->
    <add key="ClientId" value="{CLIENT-ID}" />
    <add key="ClientSecret" value="{CLIENT-SECRETD}" />

    <!-- Update the port of the Redirect URI (don't forget to set this value also in the Google API Console) -->
      <add key="RedirectUri" value="http://localhost:{PORT}/Account/GoogleAuthorization" />
  </appSettings>
  <system.web>
  ...
</configuration>
</xml>

You can remove the existing Google Calendar api and add Google Contacts Api.

Give this a try.

This has Oauth implementation and works, but the code samples from the code.google.com don't.

Is the best I found so far.

radu florescu
  • 4,315
  • 10
  • 60
  • 92