Git Product home page Git Product logo

connect-googlecontacts's Introduction

GooglePosta

A Laposta / Google Contacts (GC) API bridge

Dependencies

  • Composer
  • PHP >= 5.3.3
  • PHP JSON
  • PHP CURL
  • PHP Mcrypt

Install

Step 1 - Get the source and install source dependencies

git clone https://github.com/laposta/googleposta.git googleposta \
  && cd googleposta \
  && composer install --no-dev --prefer-dist --optimize-autoloader

Step 2 - Ensure that data directory is writable

chown apache:apache data
# or
chmod ugo+w data

Step 3 - Create your virtual host on apache or nginx

Use the public directory as you virtual hosts web root. SSL is highly recommended though not a requirement for this application.

Configure

The config.php file contains default values for the application to be run without a customized configuration. Only production values should be added to this file. A config.local.php file can be created alongside this file where values can be overridden.

Use the following command to safely create a copy for your application instance:

cp -n config.php config.local.php

or for a documentation free copy use:

php -r "file_exists('config.local.php') || \
file_put_contents('config.local.php', \"<?php\n\nreturn \".var_export(require 'config.php', true).\";\n\");"

Use your preferred editor to modify the config.local.php file for your specific requirements.

Use

Connecting a laposta account to GC

To enable a new connection between Laposta and GC the following options must be sent to https://{googleposta_host}/authority/ using the POST method.

  • email - Laposta account holder email
  • lapostaApiToken - Laposta API key
  • returnUrl (optional) - Return URL

An example using an HTML form:

<form method="post" action="https://{googleposta_host}/authority/">
    <input type="hidden" name="email" value="{laposta_login}" />
    <input type="hidden" name="lapostaApiToken" value="{laposta_api_key}" />
    <input type="hidden" name="returnUrl" value="{return_url}" />

    <input type="submit" value="Yes, Do it!" />
</form>

The user will be presented with Google's API consent screen (Or google sign in page if not already signed in followed by the latter). After confirming consent for Googleposta to access the users contacts within GC he/she will be redirected back to the return url (if provided).

The return url will receive a query string status value indicating the success or failure of the import with values 'ok' or 'fail' respectively.

Removing an existing connection

To remove connection between Laposta and GC the following options must be sent to https://{googleposta_host}/authority/delete using the POST method. The same can be accomplished by sending the same to https://{googleposta_host}/authority/ using the DELETE method.

  • email - Laposta account holder email
  • lapostaApiToken - Laposta API key
  • returnUrl (optional) - Return URL

An example using an HTML form:

<form method="post" action="https://{googleposta_host}/authority/delete">
    <input type="hidden" name="email" value="{laposta_login}" />
    <input type="hidden" name="lapostaApiToken" value="{laposta_api_key}" />
    <input type="hidden" name="returnUrl" value="{return_url}" />

    <input type="submit" value="Yes, Delete it!" />
</form>

All data caches in googleposta belonging to the user are removed and the authorisation keys allowing googleposta to connect to GC are deleted. The user will then be redirected back to the return url (if provided).

The return url will receive a query string status value indicating the success or failure of the import with values 'ok' or 'fail' respectively.

Trigger synchronisation of accounts

To import contacts from GC into laposta the following options must be sent to https://{googleposta_host}/sync/import using the POST method.

  • email - Laposta account holder email
  • lapostaApiToken - Laposta API key
  • returnUrl (optional) - Return URL

An example using an HTML form:

<form method="post" action="https://{googleposta_host}/sync/import">
    <input type="hidden" name="email" value="{laposta_login}" />
    <input type="hidden" name="lapostaApiToken" value="{laposta_api_key}" />
    <input type="hidden" name="returnUrl" value="{return_url}" />

    <input type="submit" value="Yes, Import them all!" />
</form>

Once complete, the user will then be redirected back to the return url (if provided).

The return url will receive a query string status value indicating the success or failure of the import with values 'ok' or 'fail' respectively.

Remove all lists and reset import marker

** USE WITH EXTREME CAUTION: ALL LISTS ON THE LAPOSTA ACCOUNT WILL BE REMOVED **

To reset a laposta bridge the following options must be sent to https://{googleposta_host}/sync/reset using the POST method.

  • email - Laposta account holder email
  • lapostaApiToken - Laposta API key
  • returnUrl (optional) - Return URL

An example using an HTML form:

<form method="post" action="https://{googleposta_host}/sync/reset">
    <input type="hidden" name="email" value="{laposta_login}" />
    <input type="hidden" name="lapostaApiToken" value="{laposta_api_key}" />
    <input type="hidden" name="returnUrl" value="{return_url}" />

    <input type="submit" value="Yes, Remove everything!" />
</form>

Once complete, the user will then be redirected back to the return url (if provided).

The return url will receive a query string status value indicating the success or failure of the import with values 'ok' or 'fail' respectively.

connect-googlecontacts's People

Contributors

mertenvg avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.