Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Hello World example for the Google Contacts API in Java, C#, Python or Ruby?

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:

  • Google Contacts API v3
  • API Directory
  • Contacts Reference Guide

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

like image 752
Lernkurve Avatar asked Oct 12 '12 19:10

Lernkurve


1 Answers

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.

like image 51
radu florescu Avatar answered Sep 17 '22 04:09

radu florescu