├── .gitignore
├── .htaccess
├── config.php
├── php-google-contacts-v3-api
├── .styleci.yml
├── .config_blank.json
├── vendor
│ ├── google
│ │ └── apiclient
│ │ │ ├── tests
│ │ │ ├── README
│ │ │ ├── general
│ │ │ │ ├── testdata
│ │ │ │ │ ├── cert.p12
│ │ │ │ │ ├── test.ini
│ │ │ │ │ ├── privkey.pem
│ │ │ │ │ ├── service-rsa-12345.json
│ │ │ │ │ ├── cacert.json
│ │ │ │ │ ├── cacert.pem
│ │ │ │ │ ├── service-12345.json
│ │ │ │ │ └── test_public_key.pem
│ │ │ │ ├── Http
│ │ │ │ │ ├── RequestTest.php
│ │ │ │ │ └── BatchTest.php
│ │ │ │ ├── ApiBatchRequestTest.php
│ │ │ │ ├── ComputeEngineAuthTest.php
│ │ │ │ ├── RequestTest.php
│ │ │ │ ├── ServiceTest.php
│ │ │ │ ├── ApiMediaFileUploadTest.php
│ │ │ │ ├── CacheTest.php
│ │ │ │ └── ResourceTest.php
│ │ │ ├── bootstrap.php
│ │ │ ├── pagespeed
│ │ │ │ └── PageSpeedTest.php
│ │ │ ├── urlshortener
│ │ │ │ └── UrlShortenerTests.php
│ │ │ ├── OAuthHelper.php
│ │ │ ├── BaseTest.php
│ │ │ ├── plus
│ │ │ │ └── PlusTest.php
│ │ │ ├── tasks
│ │ │ │ └── TasksTest.php
│ │ │ └── youtube
│ │ │ │ └── YouTubeTest.php
│ │ │ ├── .gitignore
│ │ │ ├── composer.json
│ │ │ ├── src
│ │ │ └── Google
│ │ │ │ ├── Exception.php
│ │ │ │ ├── Auth
│ │ │ │ ├── Exception.php
│ │ │ │ ├── Abstract.php
│ │ │ │ ├── LoginTicket.php
│ │ │ │ ├── Simple.php
│ │ │ │ ├── AppIdentity.php
│ │ │ │ ├── AssertionCredentials.php
│ │ │ │ └── ComputeEngine.php
│ │ │ │ ├── Cache
│ │ │ │ ├── Exception.php
│ │ │ │ ├── Null.php
│ │ │ │ ├── Abstract.php
│ │ │ │ └── Apc.php
│ │ │ │ ├── Task
│ │ │ │ ├── Exception.php
│ │ │ │ └── Retryable.php
│ │ │ │ ├── Logger
│ │ │ │ ├── Exception.php
│ │ │ │ ├── Null.php
│ │ │ │ ├── Psr.php
│ │ │ │ └── File.php
│ │ │ │ ├── Signer
│ │ │ │ ├── Abstract.php
│ │ │ │ └── P12.php
│ │ │ │ ├── Verifier
│ │ │ │ ├── Abstract.php
│ │ │ │ └── Pem.php
│ │ │ │ ├── autoload.php
│ │ │ │ ├── Service.php
│ │ │ │ ├── Service
│ │ │ │ ├── Cloudsearch.php
│ │ │ │ ├── Exception.php
│ │ │ │ └── GroupsMigration.php
│ │ │ │ ├── IO
│ │ │ │ └── Exception.php
│ │ │ │ ├── Collection.php
│ │ │ │ ├── Utils.php
│ │ │ │ └── Http
│ │ │ │ └── Batch.php
│ │ │ ├── examples
│ │ │ ├── index.php
│ │ │ ├── appengineauth.php
│ │ │ ├── styles
│ │ │ │ └── style.css
│ │ │ ├── templates
│ │ │ │ └── base.php
│ │ │ ├── batch.php
│ │ │ ├── simple-query.php
│ │ │ ├── service-account.php
│ │ │ ├── idtoken.php
│ │ │ ├── simplefileupload.php
│ │ │ └── multi-api.php
│ │ │ ├── autoload.php
│ │ │ ├── .travis.yml
│ │ │ ├── phpunit.xml.dist
│ │ │ └── CONTRIBUTING.md
│ ├── autoload.php
│ └── composer
│ │ ├── autoload_classmap.php
│ │ ├── autoload_namespaces.php
│ │ ├── autoload_psr4.php
│ │ ├── autoload_files.php
│ │ ├── LICENSE
│ │ ├── autoload_static.php
│ │ ├── installed.json
│ │ └── autoload_real.php
├── objects
│ └── Contact.php
├── test.php
├── composer.json
├── test_individual.php
├── authorise-application.php
├── LICENSE
├── redirect-handler.php
├── README.md
├── composer.lock
└── helpers
│ └── GoogleHelper.php
├── img
├── ATM_logo.jpg
├── googlecontactsync.png
├── object_googlecontactsync.png
└── Dolibarr_Preferred_Partner_logo.png
├── script
├── create-maj-base.php
├── sync-all-contact-for-user.php
├── import-from-zenfusioncontact.php
└── interface.php
├── js
└── checker.js.php
├── README
├── langs
├── en_US
│ └── googlecontactsync.lang
└── fr_FR
│ └── googlecontactsync.lang
├── config.default.php
├── lib
└── googlecontactsync.lib.php
├── admin
└── googlecontactsync_about.php
└── core
└── boxes
└── googlecontactsync_box.php
/.gitignore:
--------------------------------------------------------------------------------
1 | .settings/
2 | .project
3 |
4 | *.log
5 | /nbproject
--------------------------------------------------------------------------------
/.htaccess:
--------------------------------------------------------------------------------
1 | AuthType none
2 | Satisfy Any
3 | Allow from All
4 |
--------------------------------------------------------------------------------
/config.php:
--------------------------------------------------------------------------------
1 | array($baseDir . '/'),
10 | );
11 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/objects/Contact.php:
--------------------------------------------------------------------------------
1 | $value) {
10 | $this->$key = $value;
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/composer/autoload_files.php:
--------------------------------------------------------------------------------
1 | $vendorDir . '/google/apiclient/src/Google/autoload.php',
10 | );
11 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/test.php:
--------------------------------------------------------------------------------
1 | init_db_by_vars($PDOdb);
20 |
21 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/testdata/privkey.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIBOwIBAAJBAM4Aozh3TMZYcPx7MHlnD8MtyVUjzo6OdT32JwRHzHHNMMm88lNV
3 | fLYIT9C/jgXlDqG0h5wSClMvTQbdihNdFOkCAwEAAQJBAJuMo7KpcpF6iqY7Jtkk
4 | 1yQb2KCvTvMZ4rGMwt1akaeDW2noyqCeO675gFBtlizgcRsybealQVQgGX4E5VqF
5 | UJkCIQDzJZZi2jloDXcyyy2rEa4mj4RnrnIYsDMJ55XMWJ9c9wIhANjkY97FSRX3
6 | WSdRFqXd3Pc4URUho+rCcPibafMOwAUfAiAa58ngXm2DyhmqkTkYePhgY/kuz+ro
7 | OHctXWcCGbxouQIgLC5qAakieC0Ipi+oc2U8a8e3DJzrrRiqtpnB/VcV2nUCIQC2
8 | DXrpyt6jjVIzs4jI5Cl3QGLL6TZ8FqpyonU/1ARuhA==
9 | -----END RSA PRIVATE KEY-----
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rapidwebltd/php-google-contacts-v3-api",
3 | "type": "library",
4 | "description": "PHP library for the Google Contacts API (v3)",
5 | "keywords": ["google", "php", "contacts"],
6 | "homepage": "https://github.com/rapidwebltd/php-google-contacts-v3-api",
7 | "license": "MIT",
8 | "require": {
9 | "php": ">=5.2.1",
10 | "google/apiclient": ">=1.1.4 <2.0.0"
11 | },
12 | "autoload": {
13 | "psr-4": {
14 | "rapidweb\\googlecontacts\\": "."
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/js/checker.js.php:
--------------------------------------------------------------------------------
1 | googlecontactsync->enabled) || !empty($conf->global->GSC_DISABLE_JS_SYNC)) exit;
5 |
6 | ?>
7 | $(document).ready(function() {
8 | console.log('Please, enable GSC_DISABLE_JS_SYNC and use cron job');
9 | window.setTimeout(gcscksync,5000);
10 |
11 | });
12 |
13 | function gcscksync() {
14 |
15 | $.ajax({
16 | url:''
17 | ,dataType:'json'
18 | }).done(function(data) {
19 |
20 | })
21 | }
22 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/test_individual.php:
--------------------------------------------------------------------------------
1 | name = 'Test';
16 | $contact->phoneNumber = '07812363789';
17 | $contact->email = 'test@example.com';
18 |
19 | $contactAfterUpdate = ContactFactory::submitUpdates($user, $contact);
20 |
21 | var_dump($contactAfterUpdate);
22 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "google/apiclient",
3 | "type": "library",
4 | "description": "Client library for Google APIs",
5 | "keywords": ["google"],
6 | "homepage": "http://developers.google.com/api-client-library/php",
7 | "license": "Apache-2.0",
8 | "require": {
9 | "php": ">=5.2.1"
10 | },
11 | "require-dev": {
12 | "phpunit/phpunit": "3.7.*",
13 | "squizlabs/php_codesniffer": "~2.3"
14 | },
15 | "autoload": {
16 | "files": ["src/Google/autoload.php"]
17 | },
18 | "extra": {
19 | "branch-alias": {
20 | "dev-v1-master": "1.1.x-dev"
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Exception.php:
--------------------------------------------------------------------------------
1 |
3 | *
4 | * This program and files/directory inner it is free software: you can
5 | * redistribute it and/or modify it under the terms of the
6 | * GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 |
20 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/testdata/service-rsa-12345.json:
--------------------------------------------------------------------------------
1 | {
2 | "private_key_id": "1936f241be592afc6f3a6d309f75cbf5229d3e75",
3 | "private_key": "-----BEGIN RSA PRIVATE KEY-----MIIBOwIBAAJBAM4Aozh3TMZYcPx7MHlnD8MtyVUjzo6OdT32JwRHzHHNMMm88lNVfLYIT9C/jgXlDqG0h5wSClMvTQbdihNdFOkCAwEAAQJBAJuMo7KpcpF6iqY7Jtkk1yQb2KCvTvMZ4rGMwt1akaeDW2noyqCeO675gFBtlizgcRsybealQVQgGX4E5VqFUJkCIQDzJZZi2jloDXcyyy2rEa4mj4RnrnIYsDMJ55XMWJ9c9wIhANjkY97FSRX3WSdRFqXd3Pc4URUho+rCcPibafMOwAUfAiAa58ngXm2DyhmqkTkYePhgY/kuz+roOHctXWcCGbxouQIgLC5qAakieC0Ipi+oc2U8a8e3DJzrrRiqtpnB/VcV2nUCIQC2DXrpyt6jjVIzs4jI5Cl3QGLL6TZ8FqpyonU/1ARuhA==-----END RSA PRIVATE KEY-----",
4 | "client_email": "12345-is5nq94smihmoa2k0567jab6u6vj278c@developer.gserviceaccount.com",
5 | "client_id": "12345-is5nq94smihmoa2k0567jab6u6vj278c.apps.googleusercontent.com",
6 | "type": "service_account"
7 | }
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/bootstrap.php:
--------------------------------------------------------------------------------
1 | ATM Consulting You can find the documentation on our wiki For any question or feedback, contact us on support@atm-consulting.fr For any commercial question, contact us on contact@atm-consulting.fr or at +33 9 77 19 50 70 Find our other modules on Dolistore
5 |
6 | googleContactSyncSetup = googleContactSync module setup
7 | googleContactSyncAbout = About googleContactSync
8 |
9 | DolibarrURL=Dolibarr URL
10 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Signer/Abstract.php:
--------------------------------------------------------------------------------
1 |
22 | */
23 | abstract class Google_Signer_Abstract
24 | {
25 | /**
26 | * Signs data, returns the signature as binary data.
27 | */
28 | abstract public function sign($data);
29 | }
30 |
--------------------------------------------------------------------------------
/config.default.php:
--------------------------------------------------------------------------------
1 | trans('AbricotNotFound'). ' : Abricot ';
27 | exit;
28 | }
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/testdata/cacert.json:
--------------------------------------------------------------------------------
1 | {"a": "-----BEGIN CERTIFICATE-----\nMIICrDCCAlagAwIBAgIJAIhhwVyFHrVfMA0GCSqGSIb3DQEBBQUAMG8xCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQxCjAIBgNVBAsTAWExCjAIBgNVBAMTAWIxEDAOBgkqhkiG\n9w0BCQEWAWMwHhcNMTIwMjE5MDExMzQxWhcNMTUwMjE4MDExMzQxWjBvMQswCQYD\nVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQg\nV2lkZ2l0cyBQdHkgTHRkMQowCAYDVQQLEwFhMQowCAYDVQQDEwFiMRAwDgYJKoZI\nhvcNAQkBFgFjMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAM4Aozh3TMZYcPx7MHln\nD8MtyVUjzo6OdT32JwRHzHHNMMm88lNVfLYIT9C/jgXlDqG0h5wSClMvTQbdihNd\nFOkCAwEAAaOB1DCB0TAdBgNVHQ4EFgQUv0Ahb7HD9TLfdtLeaatjFj91NqYwgaEG\nA1UdIwSBmTCBloAUv0Ahb7HD9TLfdtLeaatjFj91Nqahc6RxMG8xCzAJBgNVBAYT\nAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRn\naXRzIFB0eSBMdGQxCjAIBgNVBAsTAWExCjAIBgNVBAMTAWIxEDAOBgkqhkiG9w0B\nCQEWAWOCCQCIYcFchR61XzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA0EA\nKAbxbWHsaVPnYc0YqG/Pn4HbcI1+xnVQSt3hdzq+yC0lP9H7hBMCVSykhhBkZ5XQ\nHA2t6LHuYsjcCO+LBX/4fA==\n-----END CERTIFICATE-----"}
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/examples/index.php:
--------------------------------------------------------------------------------
1 |
9 |
19 |
22 | */
23 | abstract class Google_Verifier_Abstract
24 | {
25 | /**
26 | * Checks a signature, returns true if the signature is correct,
27 | * false otherwise.
28 | */
29 | abstract public function verify($data, $signature);
30 | }
31 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/testdata/cacert.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIICrDCCAlagAwIBAgIJAIhhwVyFHrVfMA0GCSqGSIb3DQEBBQUAMG8xCzAJBgNV
3 | BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
4 | aWRnaXRzIFB0eSBMdGQxCjAIBgNVBAsTAWExCjAIBgNVBAMTAWIxEDAOBgkqhkiG
5 | 9w0BCQEWAWMwHhcNMTIwMjE5MDExMzQxWhcNMTUwMjE4MDExMzQxWjBvMQswCQYD
6 | VQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQg
7 | V2lkZ2l0cyBQdHkgTHRkMQowCAYDVQQLEwFhMQowCAYDVQQDEwFiMRAwDgYJKoZI
8 | hvcNAQkBFgFjMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAM4Aozh3TMZYcPx7MHln
9 | D8MtyVUjzo6OdT32JwRHzHHNMMm88lNVfLYIT9C/jgXlDqG0h5wSClMvTQbdihNd
10 | FOkCAwEAAaOB1DCB0TAdBgNVHQ4EFgQUv0Ahb7HD9TLfdtLeaatjFj91NqYwgaEG
11 | A1UdIwSBmTCBloAUv0Ahb7HD9TLfdtLeaatjFj91Nqahc6RxMG8xCzAJBgNVBAYT
12 | AkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRn
13 | aXRzIFB0eSBMdGQxCjAIBgNVBAsTAWExCjAIBgNVBAMTAWIxEDAOBgkqhkiG9w0B
14 | CQEWAWOCCQCIYcFchR61XzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA0EA
15 | KAbxbWHsaVPnYc0YqG/Pn4HbcI1+xnVQSt3hdzq+yC0lP9H7hBMCVSykhhBkZ5XQ
16 | HA2t6LHuYsjcCO+LBX/4fA==
17 | -----END CERTIFICATE-----
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Rapid Web Ltd
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/composer/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Copyright (c) 2016 Nils Adermann, Jordi Boggiano
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is furnished
9 | to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 |
22 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/composer/autoload_static.php:
--------------------------------------------------------------------------------
1 | __DIR__ . '/..' . '/google/apiclient/src/Google/autoload.php',
11 | );
12 |
13 | public static $prefixLengthsPsr4 = array (
14 | 'r' =>
15 | array (
16 | 'rapidweb\\googlecontacts\\' => 24,
17 | ),
18 | );
19 |
20 | public static $prefixDirsPsr4 = array (
21 | 'rapidweb\\googlecontacts\\' =>
22 | array (
23 | 0 => __DIR__ . '/../..' . '/',
24 | ),
25 | );
26 |
27 | public static function getInitializer(ClassLoader $loader)
28 | {
29 | return \Closure::bind(function () use ($loader) {
30 | $loader->prefixLengthsPsr4 = ComposerStaticInit71ef70cfd9fff78164c33a9f2156a58e::$prefixLengthsPsr4;
31 | $loader->prefixDirsPsr4 = ComposerStaticInit71ef70cfd9fff78164c33a9f2156a58e::$prefixDirsPsr4;
32 |
33 | }, null, ClassLoader::class);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/autoload.php:
--------------------------------------------------------------------------------
1 | modules_parts['triggers']=array();
18 |
19 | dol_include_once('/googlecontactsync/class/gcs.class.php');
20 |
21 | define('GCS_NO_TOKEN',true);
22 |
23 | require __DIR__.'/vendor/autoload.php';
24 | use rapidweb\googlecontacts\helpers\GoogleHelper;
25 | $client = GoogleHelper::getClient();
26 | GoogleHelper::authenticate($client, $code);
27 | $accessToken = GoogleHelper::getAccessToken($client);
28 |
29 | $PDOdb=new \TPDOdb;
30 | $token = new \TGCSToken;
31 |
32 | $token->loadByObject($PDOdb, $fk_user, 'user');
33 | $token->token = $accessToken->access_token;
34 | $token->refresh_token = $accessToken->refresh_token;
35 | $token->type_object='user';
36 | $token->fk_object = $fk_user;
37 | $PDOdb->debug = true;
38 | $token->save($PDOdb);
39 | //exit;
40 |
41 | $user_card_url = (DOL_VERSION < 3.6) ? '/user/fiche.php' : '/user/card.php';
42 | header('location:'.dol_buildpath($user_card_url,1).'?id='.$fk_user);
43 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | services:
4 | - memcached
5 |
6 | env:
7 | global:
8 | - MEMCACHE_HOST=127.0.0.1
9 | - MEMCACHE_PORT=11211
10 |
11 | sudo: false
12 |
13 | cache:
14 | directories:
15 | - $HOME/.composer/cache
16 |
17 | matrix:
18 | fast_finish: true
19 | include:
20 | # Can't test against 5.2; openssl is not available:
21 | # http://docs.travis-ci.com/user/languages/php/#PHP-installation
22 | - php: 5.3
23 | - php: 5.4
24 | - php: 5.5
25 | - php: 5.6
26 | env: PHPCS=true
27 | - php: hhvm
28 |
29 | before_install:
30 | - composer self-update
31 |
32 | install:
33 | - composer install
34 |
35 | before_script:
36 | - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension=memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
37 | - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension=memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
38 | - phpenv version-name | grep ^5.[34] && echo "extension=apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true
39 | - phpenv version-name | grep ^5.[34] && echo "apc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true
40 |
41 | script:
42 | - vendor/bin/phpunit
43 | - if [[ "$PHPCS" == "true" ]]; then vendor/bin/phpcs src --standard=style/ruleset.xml -np; fi
44 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | tests/youtube
9 |
10 |
11 | tests/tasks
12 |
13 |
14 | tests/pagespeed
15 |
16 |
17 | tests/urlshortener
18 |
19 |
20 | tests/plus
21 |
22 |
23 | tests/adsense
24 |
25 |
26 | tests/general
27 |
28 |
29 |
30 |
31 | tests
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Auth/Abstract.php:
--------------------------------------------------------------------------------
1 |
25 | *
26 | */
27 | abstract class Google_Auth_Abstract
28 | {
29 | /**
30 | * An utility function that first calls $this->auth->sign($request) and then
31 | * executes makeRequest() on that signed request. Used for when a request
32 | * should be authenticated
33 | * @param Google_Http_Request $request
34 | * @return Google_Http_Request $request
35 | */
36 | abstract public function authenticatedRequest(Google_Http_Request $request);
37 | abstract public function sign(Google_Http_Request $request);
38 | }
39 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Cache/Null.php:
--------------------------------------------------------------------------------
1 | client = $client;
31 | }
32 |
33 | /**
34 | * Return the associated Google_Client class.
35 | * @return Google_Client
36 | */
37 | public function getClient()
38 | {
39 | return $this->client;
40 | }
41 |
42 | /**
43 | * Create a new HTTP Batch handler for this service
44 | *
45 | * @return Google_Http_Batch
46 | */
47 | public function createBatch()
48 | {
49 | return new Google_Http_Batch(
50 | $this->client,
51 | false,
52 | $this->rootUrl,
53 | $this->batchPath
54 | );
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/pagespeed/PageSpeedTest.php:
--------------------------------------------------------------------------------
1 | service = new Google_Service_Pagespeedonline($this->getClient());
25 | }
26 |
27 | public function testPageSpeed()
28 | {
29 | $this->checkToken();
30 | $psapi = $this->service->pagespeedapi;
31 | $result = $psapi->runpagespeed('http://code.google.com');
32 | $this->assertArrayHasKey('kind', $result);
33 | $this->assertArrayHasKey('id', $result);
34 | $this->assertArrayHasKey('responseCode', $result);
35 | $this->assertArrayHasKey('title', $result);
36 | $this->assertArrayHasKey('score', $result->ruleGroups['SPEED']);
37 | $this->assertInstanceOf('Google_Service_Pagespeedonline_ResultPageStats', $result->pageStats);
38 | $this->assertArrayHasKey('minor', $result['version']);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/urlshortener/UrlShortenerTests.php:
--------------------------------------------------------------------------------
1 | service = new Google_Service_Urlshortener($this->getClient());
27 | }
28 |
29 | public function testUrlShort()
30 | {
31 | $url = new Google_Service_Urlshortener_Url();
32 | $url->longUrl = "http://google.com";
33 |
34 | $shortUrl = $this->service->url->insert($url);
35 | $this->assertEquals('urlshortener#url', $shortUrl['kind']);
36 | $this->assertEquals('http://google.com/', $shortUrl['longUrl']);
37 | }
38 |
39 | public function testEmptyJsonResponse()
40 | {
41 | $optParams = array('fields' => '');
42 | $resp = $this->service->url->get('http://goo.gl/KkHq8', $optParams);
43 |
44 | $this->assertEquals("", $resp->longUrl);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/composer/installed.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "google/apiclient",
4 | "version": "v1.1.8",
5 | "version_normalized": "1.1.8.0",
6 | "source": {
7 | "type": "git",
8 | "url": "https://github.com/google/google-api-php-client.git",
9 | "reference": "85309a3520bb5f53368d43e35fd24f43c9556323"
10 | },
11 | "dist": {
12 | "type": "zip",
13 | "url": "https://api.github.com/repos/google/google-api-php-client/zipball/85309a3520bb5f53368d43e35fd24f43c9556323",
14 | "reference": "85309a3520bb5f53368d43e35fd24f43c9556323",
15 | "shasum": ""
16 | },
17 | "require": {
18 | "php": ">=5.2.1"
19 | },
20 | "require-dev": {
21 | "phpunit/phpunit": "3.7.*",
22 | "squizlabs/php_codesniffer": "~2.3"
23 | },
24 | "time": "2016-06-06 21:22:48",
25 | "type": "library",
26 | "extra": {
27 | "branch-alias": {
28 | "dev-v1-master": "1.1.x-dev"
29 | }
30 | },
31 | "installation-source": "dist",
32 | "autoload": {
33 | "files": [
34 | "src/Google/autoload.php"
35 | ]
36 | },
37 | "notification-url": "https://packagist.org/downloads/",
38 | "license": [
39 | "Apache-2.0"
40 | ],
41 | "description": "Client library for Google APIs",
42 | "homepage": "http://developers.google.com/api-client-library/php",
43 | "keywords": [
44 | "google"
45 | ]
46 | }
47 | ]
48 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Service/Cloudsearch.php:
--------------------------------------------------------------------------------
1 |
22 | * The Google Cloud Search API defines an application interface to index
23 | * documents that contain structured data and to search those indexes. It
24 | * supports full text search.
25 | *
26 | *
27 | * For more information about this service, see the API
28 | * Documentation
29 | *
30 | *
31 | * @author Google, Inc.
32 | */
33 | class Google_Service_Cloudsearch extends Google_Service
34 | {
35 |
36 |
37 |
38 |
39 |
40 | /**
41 | * Constructs the internal representation of the Cloudsearch service.
42 | *
43 | * @param Google_Client $client
44 | */
45 | public function __construct(Google_Client $client)
46 | {
47 | parent::__construct($client);
48 | $this->servicePath = '';
49 | $this->version = 'v1';
50 | $this->serviceName = 'cloudsearch';
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to become a contributor and submit your own code
2 |
3 | ## Contributor License Agreements
4 |
5 | We'd love to accept your code patches! However, before we can take them, we have to jump a couple of legal hurdles.
6 |
7 | Please fill out either the individual or corporate Contributor License Agreement (CLA).
8 |
9 | * If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html).
10 | * If you work for a company that wants to allow you to contribute your work to this client library, then you'll need to sign a[corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html).
11 |
12 | Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll add you to the official list of contributors and be able to accept your patches.
13 |
14 | ## Submitting Patches
15 |
16 | 1. Fork the PHP client library on GitHub
17 | 1. Decide which code you want to submit. A submission should be a set of changes that addresses one issue in the issue tracker. Please file one change per issue, and address one issue per change. If you want to make a change that doesn't have a corresponding issue in the issue tracker, please file a new ticket!
18 | 1. Ensure that your code adheres to standard PHP conventions, as used in the rest of the library.
19 | 1. Ensure that there are unit tests for your code.
20 | 1. Sign a Contributor License Agreement (see above).
21 | 1. Submit a pull request with your patch on Github.
22 |
23 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/Http/RequestTest.php:
--------------------------------------------------------------------------------
1 | assertEquals("https://api.example.com", $request->getBaseComponent());
25 | }
26 |
27 | public function testBaseComponentExplicitStripsSlashes()
28 | {
29 | $request = new Google_Http_Request("https://api.example.com/base");
30 | $request->setBaseComponent("https://other.example.com/");
31 | $this->assertEquals("https://other.example.com", $request->getBaseComponent());
32 | }
33 |
34 | public function testBaseComponentWithPathExplicitStripsSlashes()
35 | {
36 | $request = new Google_Http_Request("https://api.example.com/base");
37 | $request->setBaseComponent("https://other.example.com/path/");
38 | $this->assertEquals("https://other.example.com/path", $request->getBaseComponent());
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Cache/Abstract.php:
--------------------------------------------------------------------------------
1 |
22 | */
23 | abstract class Google_Cache_Abstract
24 | {
25 |
26 | abstract public function __construct(Google_Client $client);
27 |
28 | /**
29 | * Retrieves the data for the given key, or false if they
30 | * key is unknown or expired
31 | *
32 | * @param String $key The key who's data to retrieve
33 | * @param boolean|int $expiration Expiration time in seconds
34 | *
35 | */
36 | abstract public function get($key, $expiration = false);
37 |
38 | /**
39 | * Store the key => $value set. The $value is serialized
40 | * by this function so can be of any type
41 | *
42 | * @param string $key Key of the data
43 | * @param string $value data
44 | */
45 | abstract public function set($key, $value);
46 |
47 | /**
48 | * Removes the key/data pair for the given $key
49 | *
50 | * @param String $key
51 | */
52 | abstract public function delete($key);
53 | }
54 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/examples/appengineauth.php:
--------------------------------------------------------------------------------
1 | setApplicationName("Client_Library_Examples");
30 |
31 | $auth = new Google_Auth_AppIdentity($client);
32 | $token = $auth->authenticateForScope(Google_Service_Storage::DEVSTORAGE_READ_ONLY);
33 | if (!$token) {
34 | die("Could not authenticate to AppIdentity service");
35 | }
36 | $client->setAuth($auth);
37 |
38 | $service = new Google_Service_Storage($client);
39 | $results = $service->buckets->listBuckets(str_replace("s~", "", $_SERVER['APPLICATION_ID']));
40 |
41 | echo "Results Of Call: ";
42 | echo "";
43 | var_dump($results);
44 | echo " ";
45 |
46 | echo pageFooter(__FILE__);
47 |
--------------------------------------------------------------------------------
/script/sync-all-contact-for-user.php:
--------------------------------------------------------------------------------
1 | fetch($fk_user);
12 | if($u->id <=0 ) exit('fk_user : fetch fail');
13 | echo $u->getNomUrl(1);
14 | }
15 | else
16 | {
17 | echo "Pas de fk_user, c'est donc pour tous les users qui on un token ";
18 | }
19 |
20 |
21 | dol_include_once('/googlecontactsync/class/gcs.class.php');
22 |
23 | $PDOdb=new TPDOdb;
24 |
25 | $Tab = $PDOdb->ExecuteAsArray("
26 | SELECT rowid, 'contact' as type_object FROM ".MAIN_DB_PREFIX."socpeople WHERE 1
27 | UNION
28 | SELECT rowid, 'societe' as type_object FROM ".MAIN_DB_PREFIX."societe WHERE 1
29 | UNION
30 | SELECT rowid, 'user_object' as type_object FROM ".MAIN_DB_PREFIX."user WHERE 1
31 | ");
32 |
33 | $count = count($Tab);
34 | echo $count." ";
35 | // var_dump($Tab);
36 |
37 | $i=0;
38 | foreach($Tab as &$row) {
39 | $i++;
40 | if ($i % 100 == 0) {
41 | echo "iteration ".$i." / ".$count." ";
42 | flush();
43 | }
44 |
45 | $fk_object = $row->rowid;
46 | $type_object = $row->type_object;
47 |
48 | if ($type_object == 'societe' && empty($conf->global->GCS_GOOGLE_SYNC_THIRDPARTY)) continue;
49 | if ($type_object == 'contact' && (empty($conf->global->GCS_GOOGLE_SYNC_CONTACT) || !empty($conf->global->GCS_GOOGLE_SYNC_ALL_CONTACT_FROM_SOCIETE))) continue;
50 | if ($type_object == 'user_object' && empty($conf->global->GCS_GOOGLE_SYNC_USER)) continue;
51 |
52 | // S'occupe de passer l'attribut "to_sync" à 1 => puis la tâche cron fera la synchro
53 | if (!empty($fk_user)) TGCSToken::setSync($PDOdb, $fk_object, $type_object, $u->id);
54 | else TGCSToken::setSyncAll($PDOdb, $fk_object, $type_object);
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/README.md:
--------------------------------------------------------------------------------
1 | # php-google-contacts-v3-api
2 |
3 | [](https://styleci.io/repos/38814668)
4 |
5 | PHP library for the Google Contacts API (v3)
6 |
7 | ## Installation & Dependencies
8 |
9 | This package and its dependencies can be installed using `composer`.
10 |
11 | Just add the package to your `composer.json` file as follows and run `composer update`.
12 |
13 | ```json
14 | {
15 | "require": {
16 | "rapidwebltd/php-google-contacts-v3-api": "1.*"
17 | }
18 | }
19 | ```
20 |
21 | ## Setup
22 |
23 | 1. Install required dependencies. See the 'Dependencies' section above.
24 | 2. Copy or rename `.config_blank.json` to `.config.json`. Note the dot (`.`) at the beginning of the file name.
25 | 3. Fill in the `clientID`, `clientSecret` and `redirectUri` in `.config.json`.
26 | * Note that `redirectUri` should be configure to point towards the `redirect-handler.php` file.
27 | * The `clientID` and `clientSecret` can be found in the Google Developers console at https://console.developers.google.com/ under 'APIs & auth' -> 'Credentials', after enabling the Contacts API.
28 | 4. Go to `authorise-application.php` in a web browser. This should give you a URL to authorise your application for Google Contacts.
29 | 5. Go to the authorisation URL provided by the previous step.
30 | 6. Accept the permissions requested on the page displayed. You should then be redirected back to the `redirect-handler.php` file.
31 | 7. The page generated by the `redirect-handler.php` file should then present you with a refresh token. Copy this into your `.config.json`.
32 | 8. Setup is done!
33 |
34 | ## Usage
35 |
36 | For extensive usage instructions, please see the blog post I wrote on the subject here: http://www.rapidweb.biz/news/php-library-for-the-google-contacts-api-v3-06102593/
37 |
38 | Also, take a look at the following files for basic examples of how to retrieve contacts. They can also be used to ensure you have currently associated your Google account with the library.
39 |
40 | * `test.php`
41 | * `test_individual.php`
42 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/OAuthHelper.php:
--------------------------------------------------------------------------------
1 | setScopes(
21 | array(
22 | "https://www.googleapis.com/auth/plus.me",
23 | "https://www.googleapis.com/auth/urlshortener",
24 | "https://www.googleapis.com/auth/tasks",
25 | "https://www.googleapis.com/auth/adsense",
26 | "https://www.googleapis.com/auth/youtube"
27 | )
28 | );
29 | $client->setRedirectUri("urn:ietf:wg:oauth:2.0:oob");
30 | // Visit https://code.google.com/apis/console to
31 | // generate your oauth2_client_id, oauth2_client_secret, and to
32 | // register your oauth2_redirect_uri.
33 | $clientId = getenv('GCLOUD_CLIENT_ID') ? getenv('GCLOUD_CLIENT_ID') : null;
34 | $clientSecret = getenv('GCLOUD_CLIENT_SECRET') ? getenv('GCLOUD_CLIENT_SECRET') : null;
35 | if (!($clientId && $clientSecret)) {
36 | die("fetching a token requires GCLOUD_CLIENT_ID and GCLOUD_CLIENT_SECRET to be set\n");
37 | }
38 | $client->setClientId($clientId);
39 | $client->setClientSecret($clientSecret);
40 |
41 | $authUrl = $client->createAuthUrl();
42 |
43 | `open '$authUrl'`;
44 | echo "\nPlease enter the auth code:\n";
45 | $authCode = trim(fgets(STDIN));
46 |
47 | $accessToken = $client->authenticate($authCode);
48 | $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.accessToken';
49 | file_put_contents($file, $accessToken);
50 |
51 | echo "successfully loaded access token\n";
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/IO/Exception.php:
--------------------------------------------------------------------------------
1 | = 0) {
44 | parent::__construct($message, $code, $previous);
45 | } else {
46 | parent::__construct($message, $code);
47 | }
48 |
49 | if (is_array($retryMap)) {
50 | $this->retryMap = $retryMap;
51 | }
52 | }
53 |
54 | /**
55 | * Gets the number of times the associated task can be retried.
56 | *
57 | * NOTE: -1 is returned if the task can be retried indefinitely
58 | *
59 | * @return integer
60 | */
61 | public function allowedRetries()
62 | {
63 | if (isset($this->retryMap[$this->code])) {
64 | return $this->retryMap[$this->code];
65 | }
66 |
67 | return 0;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Auth/LoginTicket.php:
--------------------------------------------------------------------------------
1 |
26 | */
27 | class Google_Auth_LoginTicket
28 | {
29 | const USER_ATTR = "sub";
30 |
31 | // Information from id token envelope.
32 | private $envelope;
33 |
34 | // Information from id token payload.
35 | private $payload;
36 |
37 | /**
38 | * Creates a user based on the supplied token.
39 | *
40 | * @param string $envelope Header from a verified authentication token.
41 | * @param string $payload Information from a verified authentication token.
42 | */
43 | public function __construct($envelope, $payload)
44 | {
45 | $this->envelope = $envelope;
46 | $this->payload = $payload;
47 | }
48 |
49 | /**
50 | * Returns the numeric identifier for the user.
51 | * @throws Google_Auth_Exception
52 | * @return
53 | */
54 | public function getUserId()
55 | {
56 | if (array_key_exists(self::USER_ATTR, $this->payload)) {
57 | return $this->payload[self::USER_ATTR];
58 | }
59 | throw new Google_Auth_Exception("No user_id in token");
60 | }
61 |
62 | /**
63 | * Returns attributes from the login ticket. This can contain
64 | * various information about the user session.
65 | * @return array
66 | */
67 | public function getAttributes()
68 | {
69 | return array("envelope" => $this->envelope, "payload" => $this->payload);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Auth/Simple.php:
--------------------------------------------------------------------------------
1 | client = $client;
34 | }
35 |
36 | /**
37 | * Perform an authenticated / signed apiHttpRequest.
38 | * This function takes the apiHttpRequest, calls apiAuth->sign on it
39 | * (which can modify the request in what ever way fits the auth mechanism)
40 | * and then calls apiCurlIO::makeRequest on the signed request
41 | *
42 | * @param Google_Http_Request $request
43 | * @return Google_Http_Request The resulting HTTP response including the
44 | * responseHttpCode, responseHeaders and responseBody.
45 | */
46 | public function authenticatedRequest(Google_Http_Request $request)
47 | {
48 | $request = $this->sign($request);
49 | return $this->io->makeRequest($request);
50 | }
51 |
52 | public function sign(Google_Http_Request $request)
53 | {
54 | $key = $this->client->getClassConfig($this, 'developer_key');
55 | if ($key) {
56 | $this->client->getLogger()->debug(
57 | 'Simple API Access developer key authentication'
58 | );
59 | $request->setQueryParam('key', $key);
60 | }
61 | return $request;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/BaseTest.php:
--------------------------------------------------------------------------------
1 | token = $this->loadToken();
30 | $this->memcacheHost = getenv('MEMCACHE_HOST') ? getenv('MEMCACHE_HOST') : null;
31 | $this->memcachePort = getenv('MEMCACHE_PORT') ? getenv('MEMCACHE_PORT') : null;
32 | }
33 |
34 | public function getClient()
35 | {
36 | $client = new Google_Client();
37 | $client->setDeveloperKey(self::KEY);
38 | if (strlen($this->token)) {
39 | $client->setAccessToken($this->token);
40 | }
41 | if (strlen($this->memcacheHost)) {
42 | $client->setClassConfig('Google_Cache_Memcache', 'host', $this->memcacheHost);
43 | $client->setClassConfig('Google_Cache_Memcache', 'port', $this->memcachePort);
44 | }
45 | return $client;
46 | }
47 |
48 | public function checkToken()
49 | {
50 | if (!strlen($this->token)) {
51 | $this->markTestSkipped("Test requires access token\nrun \"php tests/OAuthHelper.php\"");
52 | return false;
53 | }
54 | return true;
55 | }
56 |
57 | public function loadToken()
58 | {
59 | if (file_exists($f = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.accessToken')) {
60 | $t = file_get_contents($f);
61 | if ($token = json_decode($t, true)) {
62 | if ($token['expires_in'] + $token['created'] > time()) {
63 | return $t;
64 | }
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 | "This file is @generated automatically"
6 | ],
7 | "hash": "f40ffcbb52e78e54cb99f42fe10ed345",
8 | "content-hash": "5ffe54ecca668305f0e5b5bbbb78f753",
9 | "packages": [
10 | {
11 | "name": "google/apiclient",
12 | "version": "v1.1.8",
13 | "source": {
14 | "type": "git",
15 | "url": "https://github.com/google/google-api-php-client.git",
16 | "reference": "85309a3520bb5f53368d43e35fd24f43c9556323"
17 | },
18 | "dist": {
19 | "type": "zip",
20 | "url": "https://api.github.com/repos/google/google-api-php-client/zipball/85309a3520bb5f53368d43e35fd24f43c9556323",
21 | "reference": "85309a3520bb5f53368d43e35fd24f43c9556323",
22 | "shasum": ""
23 | },
24 | "require": {
25 | "php": ">=5.2.1"
26 | },
27 | "require-dev": {
28 | "phpunit/phpunit": "3.7.*",
29 | "squizlabs/php_codesniffer": "~2.3"
30 | },
31 | "type": "library",
32 | "extra": {
33 | "branch-alias": {
34 | "dev-v1-master": "1.1.x-dev"
35 | }
36 | },
37 | "autoload": {
38 | "files": [
39 | "src/Google/autoload.php"
40 | ]
41 | },
42 | "notification-url": "https://packagist.org/downloads/",
43 | "license": [
44 | "Apache-2.0"
45 | ],
46 | "description": "Client library for Google APIs",
47 | "homepage": "http://developers.google.com/api-client-library/php",
48 | "keywords": [
49 | "google"
50 | ],
51 | "time": "2016-06-06 21:22:48"
52 | }
53 | ],
54 | "packages-dev": [],
55 | "aliases": [],
56 | "minimum-stability": "stable",
57 | "stability-flags": [],
58 | "prefer-stable": false,
59 | "prefer-lowest": false,
60 | "platform": {
61 | "php": ">=5.2.1"
62 | },
63 | "platform-dev": []
64 | }
65 |
--------------------------------------------------------------------------------
/lib/googlecontactsync.lib.php:
--------------------------------------------------------------------------------
1 |
3 | * Copyright (C) 2015 ATM Consulting
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | /**
20 | * \file lib/googlecontactsync.lib.php
21 | * \ingroup googlecontactsync
22 | * \brief This file is an example module library
23 | * Put some comments here
24 | */
25 |
26 | function googlecontactsyncAdminPrepareHead()
27 | {
28 | global $langs, $conf;
29 |
30 | $langs->load("googlecontactsync@googlecontactsync");
31 |
32 | $h = 0;
33 | $head = array();
34 |
35 | $head[$h][0] = dol_buildpath("/googlecontactsync/admin/googlecontactsync_setup.php", 1);
36 | $head[$h][1] = $langs->trans("Parameters");
37 | $head[$h][2] = 'settings';
38 | $h++;
39 | $head[$h][0] = dol_buildpath("/googlecontactsync/admin/googlecontactsync_about.php", 1);
40 | $head[$h][1] = $langs->trans("About");
41 | $head[$h][2] = 'about';
42 | $h++;
43 |
44 | // Show more tabs from modules
45 | // Entries must be declared in modules descriptor with line
46 | //$this->tabs = array(
47 | // 'entity:+tabname:Title:@googlecontactsync:/googlecontactsync/mypage.php?id=__ID__'
48 | //); // to add new tab
49 | //$this->tabs = array(
50 | // 'entity:-tabname:Title:@googlecontactsync:/googlecontactsync/mypage.php?id=__ID__'
51 | //); // to remove a tab
52 | complete_head_from_modules($conf, $langs, $object, $head, $h, 'googlecontactsync');
53 |
54 | return $head;
55 | }
56 |
57 | function _getAllContact() {
58 | global $user;
59 |
60 | require_once __DIR__.'/../php-google-contacts-v3-api/vendor/autoload.php';
61 |
62 | $_SESSION['GCS_fk_user'] = $user->id;
63 |
64 | return \rapidweb\googlecontacts\factories\ContactFactory::getAll();
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/langs/fr_FR/googlecontactsync.lang:
--------------------------------------------------------------------------------
1 | Module104029Name = Google contact sync
2 | Module104029Desc = Module de syncronisation des contacts google
3 |
4 | ATMAbout = Ce module a été développé par ATM Consulting Vous pouvez retrouver la documentation sur notre wiki Pour toute question technique ou retour, contactez-nous sur support@atm-consulting.fr Pour toute question commerciale, contactez-nous sur contact@atm-consulting.fr ou au +33 9 77 19 50 70 Retrouvez nos autres modules sur Dolistore
5 |
6 | googleContactSyncSetup = Configuration du module Google contact sync
7 | googleContactSyncAbout = A propos du module Google contact sync
8 |
9 | GCS_GOOGLE_CLIENT_ID = Google client id (https://console.developers.google.com/apis/credentials)
10 | GCS_GOOGLE_CLIENT_SECRET = Google client secret
11 | GCS_HOST = Hôte
12 | GCS_REDIRECT_URI = Url de redirection à configurer dans la console google
13 |
14 | UserHasToken=Token disponible (renouveller ?)
15 | SetYourEmailToGetToken=Définissez votre email pour obtenir un token
16 | GetYourToken =Récupérez votre token de synchronisation
17 |
18 | SyncCardToPhone=Syncroniser sur Google
19 | SyncObjectInitiated=Synchronisation de l'élément initié (peut prendre quelques minutes)
20 |
21 | GCS_GOOGLE_GROUP_NAME = Nom du groupe où ajouter les contacts (facultatif)
22 |
23 | TokenForUser=Token de synchro Google
24 |
25 | GCS_GOOGLE_SYNC_CONTACT=Synchroniser les contacts
26 | GCS_GOOGLE_SYNC_THIRDPARTY=Synchroniser les tiers
27 | GCS_GOOGLE_SYNC_USER=Synchroniser les utilisateurs
28 | GCS_GOOGLE_SYNC_CONTACT_ALL_USER=Synchroniser avec tous les utilisateurs à la création/modification d'une fiche
29 | GCS_GOOGLE_SYNC_ALL_CONTACT_FROM_SOCIETE=La synchronisation d'un tiers, synchronisera aussi la liste des contacts actifs du tiers
30 |
31 | RemoveToken=Supprimer mon token de connexion
32 | TestToken=Tester la connexion avec votre carnet d'adresse
33 |
34 | TokenSeemsKO=L'interrogation de votre carnet ne retourne aucun résultat (peut-être est-il vide ?)
35 | TokenSeemsOK=L'interrogation de votre carnet retourne des résultats
36 |
37 | DolibarrURL=URL Dolibarr
38 |
39 |
40 | GCSCronjob_label=Sync google contact
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Verifier/Pem.php:
--------------------------------------------------------------------------------
1 |
26 | */
27 | class Google_Verifier_Pem extends Google_Verifier_Abstract
28 | {
29 | private $publicKey;
30 |
31 | /**
32 | * Constructs a verifier from the supplied PEM-encoded certificate.
33 | *
34 | * $pem: a PEM encoded certificate (not a file).
35 | * @param $pem
36 | * @throws Google_Auth_Exception
37 | * @throws Google_Exception
38 | */
39 | public function __construct($pem)
40 | {
41 | if (!function_exists('openssl_x509_read')) {
42 | throw new Google_Exception('Google API PHP client needs the openssl PHP extension');
43 | }
44 | $this->publicKey = openssl_x509_read($pem);
45 | if (!$this->publicKey) {
46 | throw new Google_Auth_Exception("Unable to parse PEM: $pem");
47 | }
48 | }
49 |
50 | public function __destruct()
51 | {
52 | if ($this->publicKey) {
53 | openssl_x509_free($this->publicKey);
54 | }
55 | }
56 |
57 | /**
58 | * Verifies the signature on data.
59 | *
60 | * Returns true if the signature is valid, false otherwise.
61 | * @param $data
62 | * @param $signature
63 | * @throws Google_Auth_Exception
64 | * @return bool
65 | */
66 | public function verify($data, $signature)
67 | {
68 | $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256";
69 | $status = openssl_verify($data, $signature, $this->publicKey, $hash);
70 | if ($status === -1) {
71 | throw new Google_Auth_Exception('Signature verification error: ' . openssl_error_string());
72 | }
73 | return $status === 1;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/admin/googlecontactsync_about.php:
--------------------------------------------------------------------------------
1 |
3 | * Copyright (C) 2015 ATM Consulting
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | /**
20 | * \file admin/about.php
21 | * \ingroup googlecontactsync
22 | * \brief This file is an example about page
23 | * Put some comments here
24 | */
25 | // Dolibarr environment
26 | $res = @include("../../main.inc.php"); // From htdocs directory
27 | if (! $res) {
28 | $res = @include("../../../main.inc.php"); // From "custom" directory
29 | }
30 |
31 | // Libraries
32 | require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
33 | require_once '../lib/googlecontactsync.lib.php';
34 |
35 | // Translations
36 | $langs->load("googlecontactsync@googlecontactsync");
37 |
38 | // Access control
39 | if (! $user->admin) {
40 | accessforbidden();
41 | }
42 |
43 | /*
44 | * View
45 | */
46 | $page_name = "googleContactSyncAbout";
47 | llxHeader('', $langs->trans($page_name));
48 |
49 | // Subheader
50 | $linkback = ''
51 | . $langs->trans("BackToModuleList") . ' ';
52 | print_fiche_titre($langs->trans($page_name), $linkback);
53 |
54 | // Configuration header
55 | $head = googlecontactsyncAdminPrepareHead();
56 | dol_fiche_head(
57 | $head,
58 | 'about',
59 | $langs->trans("Module104029Name"),
60 | 0,
61 | 'googlecontactsync@googlecontactsync'
62 | );
63 |
64 | // About page goes here
65 | print '';
66 | print ''.$langs->trans('ATMAbout').'
';
67 |
68 | dol_fiche_end();
69 |
70 | print '';
71 | print ' ';
72 | print ' ';
73 |
74 | llxFooter();
75 |
76 | $db->close();
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/examples/styles/style.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2013 Google Inc.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | body {
17 | font-family: Arial,sans-serif;
18 | margin: auto;
19 | white-space: nowrap;
20 | padding: 10px;
21 | }
22 |
23 | .box {
24 | border: .5em solid #E3E9FF;
25 | -webkit-box-orient: vertical;
26 | -webkit-box-align: center;
27 |
28 | -moz-box-orient: vertical;
29 | -moz-box-align: center;
30 |
31 | display: block;
32 | box-orient: vertical;
33 | box-align: center;
34 |
35 | width: 400px;
36 | height: auto;
37 |
38 | margin: auto;
39 | padding: 10px;
40 | }
41 |
42 | .request {
43 | -webkit-box-flex: 1;
44 | -moz-box-flex: 1;
45 | box-flex: 1;
46 | }
47 |
48 | .result {
49 | -webkit-box-flex: 2;
50 | -moz-box-flex: 2;
51 | box-flex: 2;
52 | }
53 |
54 | header {
55 | color:#000;
56 | padding:2px 5px;
57 | font-size:100%;
58 | margin: auto;
59 | text-align: center
60 | }
61 |
62 | header h1.logo {
63 | margin:6px 0;
64 | padding:0;
65 | font-size:24px;
66 | line-height:20px;
67 | text-align: center
68 | }
69 |
70 | .login {
71 | font-size: 200%;
72 | display: block;
73 | margin: auto;
74 | cursor: pointer;
75 | text-align: center;
76 | font-weight: bold;
77 | color: #2779AA;
78 | line-height: normal;
79 | }
80 |
81 | .logout {
82 | font-weight: normal;
83 | margin-top: 0;
84 | }
85 |
86 | .shortened {
87 | overflow: scroll;
88 | }
89 |
90 | .url {
91 | color: #019;
92 | font-size: 100%;
93 | vertical-align: middle;
94 | padding: 1px;
95 | background-color: white;
96 | border: 1px inset;
97 | cursor: auto;
98 | margin: 0;
99 | text-indent: 0;
100 | display: inline-block;
101 | }
102 |
103 | pre.code {
104 | padding: 10px;
105 | border: .5em solid #E3E9FF;
106 | margin: 10px;
107 | height: 400px;
108 | overflow: scroll;
109 | }
110 |
111 | .warn {
112 | color: red;
113 | }
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/plus/PlusTest.php:
--------------------------------------------------------------------------------
1 | plus = new Google_Service_Plus($this->getClient());
26 | }
27 |
28 | public function testGetPerson()
29 | {
30 | $this->checkToken();
31 | $person = $this->plus->people->get("118051310819094153327");
32 | $this->assertArrayHasKey('kind', $person);
33 | $this->assertArrayHasKey('displayName', $person);
34 | $this->assertArrayHasKey('gender', $person);
35 | $this->assertArrayHasKey('id', $person);
36 | }
37 |
38 | public function testListActivities()
39 | {
40 | $this->checkToken();
41 | $activities = $this->plus->activities
42 | ->listActivities("118051310819094153327", "public");
43 |
44 | $this->assertArrayHasKey('kind', $activities);
45 | $this->assertGreaterThan(0, count($activities));
46 |
47 | // Test a variety of access methods.
48 | $this->assertItem($activities['items'][0]);
49 | $this->assertItem($activities[0]);
50 | foreach ($activities as $item) {
51 | $this->assertItem($item);
52 | break;
53 | }
54 |
55 | // Test deeper type transformations
56 | $this->assertGreaterThan(0, strlen($activities[0]->actor->displayName));
57 | }
58 |
59 | public function assertItem($item)
60 | {
61 | // assertArrayHasKey uses array_key_exists, which is not great:
62 | // it doesn't understand SPL ArrayAccess
63 | $this->assertTrue(isset($item['actor']));
64 | $this->assertInstanceOf('Google_Service_Plus_ActivityActor', $item->actor);
65 | $this->assertTrue(isset($item['actor']['displayName']));
66 | $this->assertTrue(isset($item['actor']->url));
67 | $this->assertTrue(isset($item['object']));
68 | $this->assertTrue(isset($item['access']));
69 | $this->assertTrue(isset($item['provider']));
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/composer/autoload_real.php:
--------------------------------------------------------------------------------
1 | = 50600 && !defined('HHVM_VERSION');
27 | if ($useStaticLoader) {
28 | require_once __DIR__ . '/autoload_static.php';
29 |
30 | call_user_func(\Composer\Autoload\ComposerStaticInit71ef70cfd9fff78164c33a9f2156a58e::getInitializer($loader));
31 | } else {
32 | $map = require __DIR__ . '/autoload_namespaces.php';
33 | foreach ($map as $namespace => $path) {
34 | $loader->set($namespace, $path);
35 | }
36 |
37 | $map = require __DIR__ . '/autoload_psr4.php';
38 | foreach ($map as $namespace => $path) {
39 | $loader->setPsr4($namespace, $path);
40 | }
41 |
42 | $classMap = require __DIR__ . '/autoload_classmap.php';
43 | if ($classMap) {
44 | $loader->addClassMap($classMap);
45 | }
46 | }
47 |
48 | $loader->register(true);
49 |
50 | if ($useStaticLoader) {
51 | $includeFiles = Composer\Autoload\ComposerStaticInit71ef70cfd9fff78164c33a9f2156a58e::$files;
52 | } else {
53 | $includeFiles = require __DIR__ . '/autoload_files.php';
54 | }
55 | foreach ($includeFiles as $fileIdentifier => $file) {
56 | composerRequire71ef70cfd9fff78164c33a9f2156a58e($fileIdentifier, $file);
57 | }
58 |
59 | return $loader;
60 | }
61 | }
62 |
63 | function composerRequire71ef70cfd9fff78164c33a9f2156a58e($fileIdentifier, $file)
64 | {
65 | if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66 | require $file;
67 |
68 | $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/examples/templates/base.php:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 | " . $title . "
16 |
17 |
18 | \n";
19 | if ($_SERVER['PHP_SELF'] != "/index.php") {
20 | $ret .= "Back
";
21 | }
22 | $ret .= "";
23 | }
24 | return $ret;
25 | }
26 |
27 |
28 | function pageFooter($file = null)
29 | {
30 | $ret = "";
31 | if (isWebRequest()) {
32 | // Echo the code if in an example.
33 | if ($file) {
34 | $ret .= "Code: ";
35 | $ret .= "";
36 | $ret .= htmlspecialchars(file_get_contents($file));
37 | $ret .= " ";
38 | }
39 | $ret .= "";
40 | }
41 | return $ret;
42 | }
43 |
44 | function missingApiKeyWarning()
45 | {
46 | $ret = "";
47 | if (isWebRequest()) {
48 | $ret = "
49 |
50 | Warning: You need to set a Simple API Access key from the
51 | Google API console
52 | ";
53 | } else {
54 | $ret = "Warning: You need to set a Simple API Access key from the Google API console:";
55 | $ret .= "\nhttp://developers.google.com/console\n";
56 | }
57 | return $ret;
58 | }
59 |
60 | function missingClientSecretsWarning()
61 | {
62 | $ret = "";
63 | if (isWebRequest()) {
64 | $ret = "
65 |
66 | Warning: You need to set Client ID, Client Secret and Redirect URI from the
67 | Google API console
68 | ";
69 | } else {
70 | $ret = "Warning: You need to set Client ID, Client Secret and Redirect URI from the";
71 | $ret .= " Google API console:\nhttp://developers.google.com/console\n";
72 | }
73 | return $ret;
74 | }
75 |
76 | function missingServiceAccountDetailsWarning()
77 | {
78 | $ret = "";
79 | if (isWebRequest()) {
80 | $ret = "
81 |
82 | Warning: You need to set Client ID, Email address and the location of the Key from the
83 | Google API console
84 | ";
85 | } else {
86 | $ret = "Warning: You need to set Client ID, Email address and the location of the Key from the";
87 | $ret .= " Google API console:\nhttp://developers.google.com/console\n";
88 | }
89 | return $ret;
90 | }
91 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/helpers/GoogleHelper.php:
--------------------------------------------------------------------------------
1 | clientID = $conf->global->GCS_GOOGLE_CLIENT_ID;
14 | $config->clientSecret = $conf->global->GCS_GOOGLE_CLIENT_SECRET;
15 | $config->redirectUri = dol_buildpath('/googlecontactsync/php-google-contacts-v3-api/redirect-handler.php',2);
16 | $config->developerKey = !empty($conf->global->GCS_GOOGLE_DEVELOPER_KEY) ? $conf->global->GCS_GOOGLE_DEVELOPER_KEY : '';
17 |
18 | if(!defined('GCS_NO_TOKEN')) {
19 |
20 | $PDOdb=new \TPDOdb;
21 |
22 | if(!empty($_SESSION['GCS_fk_user']))$fk_user_gcs=$_SESSION['GCS_fk_user'];
23 |
24 | $token = \TGCSToken::getTokenFor($PDOdb, $fk_user_gcs, 'user');
25 | $config->token = $token->token;
26 | $config->refresh_token = $token->refresh_token;
27 |
28 |
29 | }
30 | else{
31 | $config->token = '';
32 | $config->refresh_token = '';
33 | }
34 | //var_dump($config);exit;
35 | return $config;
36 | }
37 |
38 | public static function getClient()
39 | {
40 | $config = self::loadConfig();
41 |
42 | $client = new \Google_Client();
43 |
44 | $client->setApplicationName('Rapid Web Google Contacts API');
45 |
46 | $client->setScopes(array(/*
47 | 'https://apps-apis.google.com/a/feeds/groups/',
48 | 'https://www.googleapis.com/auth/userinfo.email',
49 | 'https://apps-apis.google.com/a/feeds/alias/',
50 | 'https://apps-apis.google.com/a/feeds/user/',*/
51 | 'https://www.google.com/m8/feeds/',
52 | /*'https://www.google.com/m8/feeds/user/',*/
53 | ));
54 |
55 | $client->setClientId($config->clientID);
56 | $client->setClientSecret($config->clientSecret);
57 | $client->setRedirectUri($config->redirectUri);
58 | $client->setAccessType('offline');
59 | $client->setApprovalPrompt('force');
60 | $client->setDeveloperKey($config->developerKey);
61 |
62 | if (isset($config->refresh_token) && $config->refresh_token) {
63 | $client->refreshToken($config->refresh_token);
64 |
65 | }
66 |
67 | return $client;
68 | }
69 |
70 | public static function getAuthUrl(\Google_Client $client)
71 | {
72 | return $client->createAuthUrl();
73 | }
74 |
75 | public static function authenticate(\Google_Client $client, $code)
76 | {
77 | $client->authenticate($code);
78 | }
79 |
80 | public static function getAccessToken(\Google_Client $client)
81 | {
82 | return json_decode($client->getAccessToken());
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Logger/Psr.php:
--------------------------------------------------------------------------------
1 | setLogger($logger);
45 | }
46 | }
47 |
48 | /**
49 | * Sets the PSR-3 logger where logging will be delegated.
50 | *
51 | * NOTE: The `$logger` should technically implement
52 | * `Psr\Log\LoggerInterface`, but we don't explicitly require this so that
53 | * we can be compatible with PHP 5.2.
54 | *
55 | * @param Psr\Log\LoggerInterface $logger The PSR-3 logger
56 | */
57 | public function setLogger(/*Psr\Log\LoggerInterface*/ $logger)
58 | {
59 | $this->logger = $logger;
60 | }
61 |
62 | /**
63 | * {@inheritdoc}
64 | */
65 | public function shouldHandle($level)
66 | {
67 | return isset($this->logger) && parent::shouldHandle($level);
68 | }
69 |
70 | /**
71 | * {@inheritdoc}
72 | */
73 | public function log($level, $message, array $context = array())
74 | {
75 | if (!$this->shouldHandle($level)) {
76 | return false;
77 | }
78 |
79 | if ($context) {
80 | $this->reverseJsonInContext($context);
81 | }
82 |
83 | $levelName = is_int($level) ? array_search($level, self::$levels) : $level;
84 | $this->logger->log($levelName, $message, $context);
85 | }
86 |
87 | /**
88 | * {@inheritdoc}
89 | */
90 | protected function write($message, array $context = array())
91 | {
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/tasks/TasksTest.php:
--------------------------------------------------------------------------------
1 | taskService = new Google_Service_Tasks($this->getClient());
27 | }
28 |
29 | public function testInsertTask()
30 | {
31 | if (!$this->checkToken()) {
32 | return;
33 | }
34 | $list = $this->createTaskList('List: ' . __METHOD__);
35 | $task = $this->createTask('Task: '.__METHOD__, $list->id);
36 | $this->assertIsTask($task);
37 | }
38 |
39 | /**
40 | * @depends testInsertTask
41 | */
42 | public function testGetTask()
43 | {
44 | $tasks = $this->taskService->tasks;
45 | $list = $this->createTaskList('List: ' . __METHOD__);
46 | $task = $this->createTask('Task: '. __METHOD__, $list['id']);
47 |
48 | $task = $tasks->get($list['id'], $task['id']);
49 | $this->assertIsTask($task);
50 | }
51 |
52 | /**
53 | * @depends testInsertTask
54 | */
55 | public function testListTask()
56 | {
57 | $tasks = $this->taskService->tasks;
58 | $list = $this->createTaskList('List: ' . __METHOD__);
59 |
60 | for ($i=0; $i<4; $i++) {
61 | $this->createTask("Task: $i ".__METHOD__, $list['id']);
62 | }
63 |
64 | $tasksArray = $tasks->listTasks($list['id']);
65 | $this->assertTrue(sizeof($tasksArray) > 1);
66 | foreach ($tasksArray['items'] as $task) {
67 | $this->assertIsTask($task);
68 | }
69 | }
70 |
71 | private function createTaskList($name)
72 | {
73 | $list = new Google_Service_Tasks_TaskList();
74 | $list->title = $name;
75 | return $this->taskService->tasklists->insert($list);
76 | }
77 |
78 | private function createTask($title, $listId)
79 | {
80 | $tasks = $this->taskService->tasks;
81 | $task = new Google_Service_Tasks_Task();
82 | $task->title = $title;
83 | return $tasks->insert($listId, $task);
84 | }
85 |
86 | private function assertIsTask($task)
87 | {
88 | $this->assertArrayHasKey('title', $task);
89 | $this->assertArrayHasKey('kind', $task);
90 | $this->assertArrayHasKey('id', $task);
91 | $this->assertArrayHasKey('position', $task);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/core/boxes/googlecontactsync_box.php:
--------------------------------------------------------------------------------
1 |
3 | * Copyright (C)
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | /**
20 | * \file core/boxes/mybox.php
21 | * \ingroup googlecontactsync
22 | * \brief This file is a sample box definition file
23 | * Put some comments here
24 | */
25 | include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php";
26 |
27 | /**
28 | * Class to manage the box
29 | */
30 | class googlecontactsyncbox extends ModeleBoxes
31 | {
32 |
33 | public $boxcode = "mybox";
34 | public $boximg = "googlecontactsync@googlecontactsync";
35 | public $boxlabel;
36 | public $depends = array("googlecontactsync");
37 | public $db;
38 | public $param;
39 | public $info_box_head = array();
40 | public $info_box_contents = array();
41 |
42 | /**
43 | * Constructor
44 | */
45 | public function __construct()
46 | {
47 | global $langs;
48 | $langs->load("boxes");
49 |
50 | $this->boxlabel = $langs->transnoentitiesnoconv("MyBox");
51 | }
52 |
53 | /**
54 | * Load data into info_box_contents array to show array later.
55 | *
56 | * @param int $max Maximum number of records to load
57 | * @return void
58 | */
59 | public function loadBox($max = 5)
60 | {
61 | global $conf, $user, $langs, $db;
62 |
63 | $this->max = $max;
64 |
65 | //include_once DOL_DOCUMENT_ROOT . "/googlecontactsync/class/googlecontactsync.class.php";
66 |
67 | $text = $langs->trans("MyBoxDescription", $max);
68 | $this->info_box_head = array(
69 | 'text' => $text,
70 | 'limit' => dol_strlen($text)
71 | );
72 |
73 | $this->info_box_contents[0][0] = array('td' => 'align="left"',
74 | 'text' => $langs->trans("MyBoxContent"));
75 | }
76 |
77 | /**
78 | * Method to show box
79 | *
80 | * @param array $head Array with properties of box title
81 | * @param array $contents Array with properties of box lines
82 | * @return void
83 | */
84 | public function showBox($head = null, $contents = null)
85 | {
86 | parent::showBox($this->info_box_head, $this->info_box_contents);
87 | }
88 | }
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/ApiBatchRequestTest.php:
--------------------------------------------------------------------------------
1 | checkToken()) {
28 | return;
29 | }
30 | $client = $this->getClient();
31 | $batch = new Google_Http_Batch($client);
32 | $this->plus = new Google_Service_Plus($client);
33 |
34 | $client->setUseBatch(true);
35 | $batch->add($this->plus->people->get('me'), 'key1');
36 | $batch->add($this->plus->people->get('me'), 'key2');
37 | $batch->add($this->plus->people->get('me'), 'key3');
38 |
39 | $result = $batch->execute();
40 | $this->assertTrue(isset($result['response-key1']));
41 | $this->assertTrue(isset($result['response-key2']));
42 | $this->assertTrue(isset($result['response-key3']));
43 | }
44 |
45 | public function testBatchRequest()
46 | {
47 | $client = $this->getClient();
48 | $batch = new Google_Http_Batch($client);
49 | $this->plus = new Google_Service_Plus($client);
50 |
51 | $client->setUseBatch(true);
52 | $batch->add($this->plus->people->get('+LarryPage'), 'key1');
53 | $batch->add($this->plus->people->get('+LarryPage'), 'key2');
54 | $batch->add($this->plus->people->get('+LarryPage'), 'key3');
55 |
56 | $result = $batch->execute();
57 | $this->assertTrue(isset($result['response-key1']));
58 | $this->assertTrue(isset($result['response-key2']));
59 | $this->assertTrue(isset($result['response-key3']));
60 | }
61 |
62 | public function testInvalidBatchRequest()
63 | {
64 | $client = $this->getClient();
65 | $batch = new Google_Http_Batch($client);
66 | $this->plus = new Google_Service_Plus($client);
67 |
68 | $client->setUseBatch(true);
69 | $batch->add($this->plus->people->get('123456789987654321'), 'key1');
70 | $batch->add($this->plus->people->get('+LarryPage'), 'key2');
71 |
72 | $result = $batch->execute();
73 | $this->assertTrue(isset($result['response-key2']));
74 | $this->assertInstanceOf(
75 | 'Google_Service_Exception',
76 | $result['response-key1']
77 | );
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Collection.php:
--------------------------------------------------------------------------------
1 | modelData[$this->collection_key])
19 | && is_array($this->modelData[$this->collection_key])) {
20 | reset($this->modelData[$this->collection_key]);
21 | }
22 | }
23 |
24 | public function current()
25 | {
26 | $this->coerceType($this->key());
27 | if (is_array($this->modelData[$this->collection_key])) {
28 | return current($this->modelData[$this->collection_key]);
29 | }
30 | }
31 |
32 | public function key()
33 | {
34 | if (isset($this->modelData[$this->collection_key])
35 | && is_array($this->modelData[$this->collection_key])) {
36 | return key($this->modelData[$this->collection_key]);
37 | }
38 | }
39 |
40 | public function next()
41 | {
42 | return next($this->modelData[$this->collection_key]);
43 | }
44 |
45 | public function valid()
46 | {
47 | $key = $this->key();
48 | return $key !== null && $key !== false;
49 | }
50 |
51 | public function count()
52 | {
53 | if (!isset($this->modelData[$this->collection_key])) {
54 | return 0;
55 | }
56 | return count($this->modelData[$this->collection_key]);
57 | }
58 |
59 | public function offsetExists($offset)
60 | {
61 | if (!is_numeric($offset)) {
62 | return parent::offsetExists($offset);
63 | }
64 | return isset($this->modelData[$this->collection_key][$offset]);
65 | }
66 |
67 | public function offsetGet($offset)
68 | {
69 | if (!is_numeric($offset)) {
70 | return parent::offsetGet($offset);
71 | }
72 | $this->coerceType($offset);
73 | return $this->modelData[$this->collection_key][$offset];
74 | }
75 |
76 | public function offsetSet($offset, $value)
77 | {
78 | if (!is_numeric($offset)) {
79 | return parent::offsetSet($offset, $value);
80 | }
81 | $this->modelData[$this->collection_key][$offset] = $value;
82 | }
83 |
84 | public function offsetUnset($offset)
85 | {
86 | if (!is_numeric($offset)) {
87 | return parent::offsetUnset($offset);
88 | }
89 | unset($this->modelData[$this->collection_key][$offset]);
90 | }
91 |
92 | private function coerceType($offset)
93 | {
94 | $typeKey = $this->keyType($this->collection_key);
95 | if (isset($this->$typeKey) && !is_object($this->modelData[$this->collection_key][$offset])) {
96 | $type = $this->$typeKey;
97 | $this->modelData[$this->collection_key][$offset] =
98 | new $type($this->modelData[$this->collection_key][$offset]);
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/ComputeEngineAuthTest.php:
--------------------------------------------------------------------------------
1 | "ACCESS_TOKEN",
31 | 'expires_in' => "12345"
32 | )
33 | );
34 | $response = $this->getMock("Google_Http_Request", array(), array(''));
35 | $response->expects($this->any())
36 | ->method('getResponseHttpCode')
37 | ->will($this->returnValue(200));
38 | $response->expects($this->any())
39 | ->method('getResponseBody')
40 | ->will($this->returnValue($response_data));
41 | $io = $this->getMock("Google_IO_Stream", array(), array($client));
42 | $client->setIo($io);$io->expects($this->any())
43 | ->method('makeRequest')
44 | ->will(
45 | $this->returnCallback(
46 | function ($request) use ($response) {
47 | return $response;
48 | }
49 | )
50 | );
51 |
52 | /* Run method */
53 | $oauth = new Google_Auth_ComputeEngine($client);
54 | $oauth->acquireAccessToken();
55 | $token = json_decode($oauth->getAccessToken(), true);
56 |
57 | /* Check results */
58 | $this->assertEquals($token['access_token'], "ACCESS_TOKEN");
59 | $this->assertEquals($token['expires_in'], "12345");
60 | $this->assertTrue($token['created'] > 0);
61 | }
62 |
63 | public function testSign()
64 | {
65 | $client = new Google_Client();
66 | $oauth = new Google_Auth_ComputeEngine($client);
67 |
68 | /* Load mock access token */
69 | $oauth->setAccessToken(
70 | json_encode(
71 | array(
72 | 'access_token' => "ACCESS_TOKEN",
73 | 'expires_in' => "12345"
74 | )
75 | )
76 | );
77 |
78 | /* Sign a URL and verify auth header is correctly set */
79 | $req = new Google_Http_Request('http://localhost');
80 | $req = $oauth->sign($req);
81 | $auth = $req->getRequestHeader('authorization');
82 | $this->assertEquals('Bearer ACCESS_TOKEN', $auth);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Service/Exception.php:
--------------------------------------------------------------------------------
1 | = 0) {
53 | parent::__construct($message, $code, $previous);
54 | } else {
55 | parent::__construct($message, $code);
56 | }
57 |
58 | $this->errors = $errors;
59 |
60 | if (is_array($retryMap)) {
61 | $this->retryMap = $retryMap;
62 | }
63 | }
64 |
65 | /**
66 | * An example of the possible errors returned.
67 | *
68 | * {
69 | * "domain": "global",
70 | * "reason": "authError",
71 | * "message": "Invalid Credentials",
72 | * "locationType": "header",
73 | * "location": "Authorization",
74 | * }
75 | *
76 | * @return [{string, string}] List of errors return in an HTTP response or [].
77 | */
78 | public function getErrors()
79 | {
80 | return $this->errors;
81 | }
82 |
83 | /**
84 | * Gets the number of times the associated task can be retried.
85 | *
86 | * NOTE: -1 is returned if the task can be retried indefinitely
87 | *
88 | * @return integer
89 | */
90 | public function allowedRetries()
91 | {
92 | if (isset($this->retryMap[$this->code])) {
93 | return $this->retryMap[$this->code];
94 | }
95 |
96 | $errors = $this->getErrors();
97 |
98 | if (!empty($errors) && isset($errors[0]['reason']) &&
99 | isset($this->retryMap[$errors[0]['reason']])) {
100 | return $this->retryMap[$errors[0]['reason']];
101 | }
102 |
103 | return 0;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/RequestTest.php:
--------------------------------------------------------------------------------
1 | setExpectedClass("Google_Client");
29 | $this->assertEquals(2, count($request->getQueryParams()));
30 | $request->setQueryParam("hi", "there");
31 | $this->assertEquals($url2, $request->getUrl());
32 | $this->assertEquals("Google_Client", $request->getExpectedClass());
33 |
34 | $urlPath = "/foo/bar";
35 | $request = new Google_Http_Request($urlPath);
36 | $this->assertEquals($urlPath, $request->getUrl());
37 | $request->setBaseComponent("http://example.com");
38 | $this->assertEquals("http://example.com" . $urlPath, $request->getUrl());
39 |
40 | $url3a = 'http://localhost:8080/foo/bar';
41 | $url3b = 'foo=a&foo=b&wowee=oh+my';
42 | $url3c = 'foo=a&foo=b&wowee=oh+my&hi=there';
43 | $request = new Google_Http_Request($url3a."?".$url3b, "POST");
44 | $request->setQueryParam("hi", "there");
45 | $request->maybeMoveParametersToBody();
46 | $this->assertEquals($url3a, $request->getUrl());
47 | $this->assertEquals($url3c, $request->getPostBody());
48 |
49 | $url4 = 'http://localhost:8080/upload/foo/bar?foo=a&foo=b&wowee=oh+my&hi=there';
50 | $request = new Google_Http_Request($url);
51 | $this->assertEquals(2, count($request->getQueryParams()));
52 | $request->setQueryParam("hi", "there");
53 | $base = $request->getBaseComponent();
54 | $request->setBaseComponent($base . '/upload');
55 | $this->assertEquals($url4, $request->getUrl());
56 | }
57 |
58 | public function testGzipSupport()
59 | {
60 | $url = 'http://localhost:8080/foo/bar?foo=a&foo=b&wowee=oh+my';
61 | $request = new Google_Http_Request($url);
62 | $request->enableGzip();
63 | $this->assertStringEndsWith(Google_Http_Request::GZIP_UA, $request->getUserAgent());
64 | $this->assertArrayHasKey('accept-encoding', $request->getRequestHeaders());
65 | $this->assertTrue($request->canGzip());
66 | $request->disableGzip();
67 | $this->assertStringEndsNotWith(Google_Http_Request::GZIP_UA, $request->getUserAgent());
68 | $this->assertArrayNotHasKey('accept-encoding', $request->getRequestHeaders());
69 | $this->assertFalse($request->canGzip());
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/examples/batch.php:
--------------------------------------------------------------------------------
1 | setApplicationName("Client_Library_Examples");
35 | $apiKey = ""; // Change to your API key.
36 | // Warn if the API key isn't changed!
37 | if (strpos($apiKey, "<") !== false) {
38 | echo missingApiKeyWarning();
39 | exit;
40 | } else {
41 | $client->setDeveloperKey($apiKey);
42 |
43 | $service = new Google_Service_Books($client);
44 |
45 | /************************************************
46 | To actually make the batch call we need to
47 | enable batching on the client - this will apply
48 | globally until we set it to false. This causes
49 | call to the service methods to return the query
50 | rather than immediately executing.
51 | ************************************************/
52 | $client->setUseBatch(true);
53 |
54 | /************************************************
55 | We then create a batch, and add each query we
56 | want to execute with keys of our choice - these
57 | keys will be reflected in the returned array.
58 | ************************************************/
59 | $batch = new Google_Http_Batch($client);
60 | $optParams = array('filter' => 'free-ebooks');
61 | $req1 = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
62 | $batch->add($req1, "thoreau");
63 | $req2 = $service->volumes->listVolumes('George Bernard Shaw', $optParams);
64 | $batch->add($req2, "shaw");
65 |
66 | /************************************************
67 | Executing the batch will send all requests off
68 | at once.
69 | ************************************************/
70 | $results = $batch->execute();
71 |
72 | echo "Results Of Call 1: ";
73 | foreach ($results['response-thoreau'] as $item) {
74 | echo $item['volumeInfo']['title'], " \n";
75 | }
76 | echo "Results Of Call 2: ";
77 | foreach ($results['response-shaw'] as $item) {
78 | echo $item['volumeInfo']['title'], " \n";
79 | }
80 | }
81 |
82 | echo pageFooter(__FILE__);
83 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Cache/Apc.php:
--------------------------------------------------------------------------------
1 |
29 | */
30 | class Google_Cache_Apc extends Google_Cache_Abstract
31 | {
32 | /**
33 | * @var Google_Client the current client
34 | */
35 | private $client;
36 |
37 | public function __construct(Google_Client $client)
38 | {
39 | if (! function_exists('apc_add') ) {
40 | $error = "Apc functions not available";
41 |
42 | $client->getLogger()->error($error);
43 | throw new Google_Cache_Exception($error);
44 | }
45 |
46 | $this->client = $client;
47 | }
48 |
49 | /**
50 | * @inheritDoc
51 | */
52 | public function get($key, $expiration = false)
53 | {
54 | $ret = apc_fetch($key);
55 | if ($ret === false) {
56 | $this->client->getLogger()->debug(
57 | 'APC cache miss',
58 | array('key' => $key)
59 | );
60 | return false;
61 | }
62 | if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) {
63 | $this->client->getLogger()->debug(
64 | 'APC cache miss (expired)',
65 | array('key' => $key, 'var' => $ret)
66 | );
67 | $this->delete($key);
68 | return false;
69 | }
70 |
71 | $this->client->getLogger()->debug(
72 | 'APC cache hit',
73 | array('key' => $key, 'var' => $ret)
74 | );
75 |
76 | return $ret['data'];
77 | }
78 |
79 | /**
80 | * @inheritDoc
81 | */
82 | public function set($key, $value)
83 | {
84 | $var = array('time' => time(), 'data' => $value);
85 | $rc = apc_store($key, $var);
86 |
87 | if ($rc == false) {
88 | $this->client->getLogger()->error(
89 | 'APC cache set failed',
90 | array('key' => $key, 'var' => $var)
91 | );
92 | throw new Google_Cache_Exception("Couldn't store data");
93 | }
94 |
95 | $this->client->getLogger()->debug(
96 | 'APC cache set',
97 | array('key' => $key, 'var' => $var)
98 | );
99 | }
100 |
101 | /**
102 | * @inheritDoc
103 | * @param String $key
104 | */
105 | public function delete($key)
106 | {
107 | $this->client->getLogger()->debug(
108 | 'APC cache delete',
109 | array('key' => $key)
110 | );
111 | apc_delete($key);
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Signer/P12.php:
--------------------------------------------------------------------------------
1 |
28 | */
29 | class Google_Signer_P12 extends Google_Signer_Abstract
30 | {
31 | // OpenSSL private key resource
32 | private $privateKey;
33 |
34 | // Creates a new signer from a .p12 file.
35 | public function __construct($p12, $password)
36 | {
37 | if (!function_exists('openssl_x509_read')) {
38 | throw new Google_Exception(
39 | 'The Google PHP API library needs the openssl PHP extension'
40 | );
41 | }
42 |
43 | // If the private key is provided directly, then this isn't in the p12
44 | // format. Different versions of openssl support different p12 formats
45 | // and the key from google wasn't being accepted by the version available
46 | // at the time.
47 | if (!$password && strpos($p12, "-----BEGIN RSA PRIVATE KEY-----") !== false) {
48 | $this->privateKey = openssl_pkey_get_private($p12);
49 | } elseif ($password === 'notasecret' && strpos($p12, "-----BEGIN PRIVATE KEY-----") !== false) {
50 | $this->privateKey = openssl_pkey_get_private($p12);
51 | } else {
52 | // This throws on error
53 | $certs = array();
54 | if (!openssl_pkcs12_read($p12, $certs, $password)) {
55 | throw new Google_Auth_Exception(
56 | "Unable to parse the p12 file. " .
57 | "Is this a .p12 file? Is the password correct? OpenSSL error: " .
58 | openssl_error_string()
59 | );
60 | }
61 | // TODO(beaton): is this part of the contract for the openssl_pkcs12_read
62 | // method? What happens if there are multiple private keys? Do we care?
63 | if (!array_key_exists("pkey", $certs) || !$certs["pkey"]) {
64 | throw new Google_Auth_Exception("No private key found in p12 file.");
65 | }
66 | $this->privateKey = openssl_pkey_get_private($certs['pkey']);
67 | }
68 |
69 | if (!$this->privateKey) {
70 | throw new Google_Auth_Exception("Unable to load private key");
71 | }
72 | }
73 |
74 | public function __destruct()
75 | {
76 | if ($this->privateKey) {
77 | openssl_pkey_free($this->privateKey);
78 | }
79 | }
80 |
81 | public function sign($data)
82 | {
83 | if (version_compare(PHP_VERSION, '5.3.0') < 0) {
84 | throw new Google_Auth_Exception(
85 | "PHP 5.3.0 or higher is required to use service accounts."
86 | );
87 | }
88 | $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256";
89 | if (!openssl_sign($data, $signature, $this->privateKey, $hash)) {
90 | throw new Google_Auth_Exception("Unable to sign data");
91 | }
92 | return $signature;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/examples/simple-query.php:
--------------------------------------------------------------------------------
1 | setApplicationName("Client_Library_Examples");
38 | $apiKey = ""; // Change this line.
39 | // Warn if the API key isn't changed.
40 | if (strpos($apiKey, "<") !== false) {
41 | echo missingApiKeyWarning();
42 | exit;
43 | }
44 | $client->setDeveloperKey($apiKey);
45 |
46 | $service = new Google_Service_Books($client);
47 |
48 | /************************************************
49 | We make a call to our service, which will
50 | normally map to the structure of the API.
51 | In this case $service is Books API, the
52 | resource is volumes, and the method is
53 | listVolumes. We pass it a required parameters
54 | (the query), and an array of named optional
55 | parameters.
56 | ************************************************/
57 | $optParams = array('filter' => 'free-ebooks');
58 | $results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
59 |
60 | /************************************************
61 | This call returns a list of volumes, so we
62 | can iterate over them as normal with any
63 | array.
64 | Some calls will return a single item which we
65 | can immediately use. The individual responses
66 | are typed as Google_Service_Books_Volume, but
67 | can be treated as an array.
68 | ***********************************************/
69 | echo "Results Of Call: ";
70 | foreach ($results as $item) {
71 | echo $item['volumeInfo']['title'], " \n";
72 | }
73 |
74 | /************************************************
75 | This is an example of deferring a call.
76 | ***********************************************/
77 | $client->setDefer(true);
78 | $optParams = array('filter' => 'free-ebooks');
79 | $request = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
80 | $results = $client->execute($request);
81 |
82 | echo "Results Of Deferred Call: ";
83 | foreach ($results as $item) {
84 | echo $item['volumeInfo']['title'], " \n";
85 | }
86 |
87 | echo pageFooter(__FILE__);
88 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/examples/service-account.php:
--------------------------------------------------------------------------------
1 | '; //Client ID
40 | $service_account_name = ''; //Email Address
41 | $key_file_location = ''; //key.p12
42 |
43 | echo pageHeader("Service Account Access");
44 | if (strpos($client_id, "googleusercontent") == false
45 | || !strlen($service_account_name)
46 | || !strlen($key_file_location)) {
47 | echo missingServiceAccountDetailsWarning();
48 | exit;
49 | }
50 |
51 | $client = new Google_Client();
52 | $client->setApplicationName("Client_Library_Examples");
53 | $service = new Google_Service_Books($client);
54 |
55 | /************************************************
56 | If we have an access token, we can carry on.
57 | Otherwise, we'll get one with the help of an
58 | assertion credential. In other examples the list
59 | of scopes was managed by the Client, but here
60 | we have to list them manually. We also supply
61 | the service account
62 | ************************************************/
63 | if (isset($_SESSION['service_token'])) {
64 | $client->setAccessToken($_SESSION['service_token']);
65 | }
66 | $key = file_get_contents($key_file_location);
67 | $cred = new Google_Auth_AssertionCredentials(
68 | $service_account_name,
69 | array('https://www.googleapis.com/auth/books'),
70 | $key
71 | );
72 | $client->setAssertionCredentials($cred);
73 | if ($client->getAuth()->isAccessTokenExpired()) {
74 | $client->getAuth()->refreshTokenWithAssertion($cred);
75 | }
76 | $_SESSION['service_token'] = $client->getAccessToken();
77 |
78 | /************************************************
79 | We're just going to make the same call as in the
80 | simple query as an example.
81 | ************************************************/
82 | $optParams = array('filter' => 'free-ebooks');
83 | $results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
84 | echo "Results Of Call: ";
85 | foreach ($results as $item) {
86 | echo $item['volumeInfo']['title'], " \n";
87 | }
88 |
89 | echo pageFooter(__FILE__);
90 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/youtube/YouTubeTest.php:
--------------------------------------------------------------------------------
1 | youtube = new Google_Service_YouTube($this->getClient());
26 | }
27 |
28 | public function testMissingFieldsAreNull()
29 | {
30 | if (!$this->checkToken()) {
31 | return;
32 | }
33 |
34 | $parts = "id,brandingSettings";
35 | $opts = array("mine" => true);
36 | $channels = $this->youtube->channels->listChannels($parts, $opts);
37 |
38 | $newChannel = new Google_Service_YouTube_Channel();
39 | $newChannel->setId($channels[0]->getId());
40 | $newChannel->setBrandingSettings($channels[0]->getBrandingSettings());
41 |
42 | $simpleOriginal = $channels[0]->toSimpleObject();
43 | $simpleNew = $newChannel->toSimpleObject();
44 |
45 | $this->assertObjectHasAttribute('etag', $simpleOriginal);
46 | $this->assertObjectNotHasAttribute('etag', $simpleNew);
47 |
48 | $owner_details = new Google_Service_YouTube_ChannelContentOwnerDetails();
49 | $owner_details->setTimeLinked("123456789");
50 | $o_channel = new Google_Service_YouTube_Channel();
51 | $o_channel->setContentOwnerDetails($owner_details);
52 | $simpleManual = $o_channel->toSimpleObject();
53 | $this->assertObjectHasAttribute('timeLinked', $simpleManual->contentOwnerDetails);
54 | $this->assertObjectNotHasAttribute('contentOwner', $simpleManual->contentOwnerDetails);
55 |
56 | $owner_details = new Google_Service_YouTube_ChannelContentOwnerDetails();
57 | $owner_details->timeLinked = "123456789";
58 | $o_channel = new Google_Service_YouTube_Channel();
59 | $o_channel->setContentOwnerDetails($owner_details);
60 | $simpleManual = $o_channel->toSimpleObject();
61 |
62 | $this->assertObjectHasAttribute('timeLinked', $simpleManual->contentOwnerDetails);
63 | $this->assertObjectNotHasAttribute('contentOwner', $simpleManual->contentOwnerDetails);
64 |
65 | $owner_details = new Google_Service_YouTube_ChannelContentOwnerDetails();
66 | $owner_details['timeLinked'] = "123456789";
67 | $o_channel = new Google_Service_YouTube_Channel();
68 | $o_channel->setContentOwnerDetails($owner_details);
69 | $simpleManual = $o_channel->toSimpleObject();
70 |
71 | $this->assertObjectHasAttribute('timeLinked', $simpleManual->contentOwnerDetails);
72 | $this->assertObjectNotHasAttribute('contentOwner', $simpleManual->contentOwnerDetails);
73 |
74 | $ping = new Google_Service_YouTube_ChannelConversionPing();
75 | $ping->setContext("hello");
76 | $pings = new Google_Service_YouTube_ChannelConversionPings();
77 | $pings->setPings(array($ping));
78 | $simplePings = $pings->toSimpleObject();
79 | $this->assertObjectHasAttribute('context', $simplePings->pings[0]);
80 | $this->assertObjectNotHasAttribute('conversionUrl', $simplePings->pings[0]);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/ServiceTest.php:
--------------------------------------------------------------------------------
1 | mapTypes(
42 | array(
43 | 'name' => 'asdf',
44 | 'gender' => 'z',
45 | )
46 | );
47 | $this->assertEquals('asdf', $model->name);
48 | $this->assertEquals('z', $model->gender);
49 | $model->mapTypes(
50 | array(
51 | '__infoType' => 'Google_Model',
52 | '__infoDataType' => 'map',
53 | 'info' => array (
54 | 'location' => 'mars',
55 | 'timezone' => 'mst',
56 | ),
57 | 'name' => 'asdf',
58 | 'gender' => 'z',
59 | )
60 | );
61 | $this->assertEquals('asdf', $model->name);
62 | $this->assertEquals('z', $model->gender);
63 |
64 | $this->assertEquals(false, $model->isAssociativeArray(""));
65 | $this->assertEquals(false, $model->isAssociativeArray(false));
66 | $this->assertEquals(false, $model->isAssociativeArray(null));
67 | $this->assertEquals(false, $model->isAssociativeArray(array()));
68 | $this->assertEquals(false, $model->isAssociativeArray(array(1, 2)));
69 | $this->assertEquals(false, $model->isAssociativeArray(array(1 => 2)));
70 |
71 | $this->assertEquals(true, $model->isAssociativeArray(array('test' => 'a')));
72 | $this->assertEquals(true, $model->isAssociativeArray(array("a", "b" => 2)));
73 | }
74 |
75 | /**
76 | * @dataProvider serviceProvider
77 | */
78 | public function testIncludes($class)
79 | {
80 | $this->assertTrue(
81 | class_exists($class),
82 | sprintf('Failed asserting class %s exists.', $class)
83 | );
84 | }
85 |
86 | public function serviceProvider()
87 | {
88 | $classes = array();
89 | $path = dirname(dirname(dirname(__FILE__))) . '/src/Google/Service';
90 | foreach (glob($path . "/*.php") as $file) {
91 | $classes[] = array('Google_Service_' . basename($file, '.php'));
92 | }
93 |
94 | return $classes;
95 | }
96 |
97 | public function testStrLen()
98 | {
99 | $this->assertEquals(0, Google_Utils::getStrLen(null));
100 | $this->assertEquals(0, Google_Utils::getStrLen(false));
101 | $this->assertEquals(0, Google_Utils::getStrLen(""));
102 |
103 | $this->assertEquals(1, Google_Utils::getStrLen(" "));
104 | $this->assertEquals(2, Google_Utils::getStrLen(" 1"));
105 | $this->assertEquals(7, Google_Utils::getStrLen("0a\\n\n\r\n"));
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/script/import-from-zenfusioncontact.php:
--------------------------------------------------------------------------------
1 | ExecuteAsArray("SELECT * FROM ".MAIN_DB_PREFIX."zenfusion_oauth WHERE token IS NOT NULL");
17 | foreach($Tab as &$row) {
18 | $fk_object = $row->rowid;
19 | $type_object = 'user';
20 | $fk_user = $user->id;
21 |
22 | $tok = json_decode($row->token);
23 |
24 | // TGCSToken::setSync($PDOdb, $object->id, $object->element, $user->id);
25 | $token = new TGCSToken;
26 | $token->loadByObject($PDOdb, $fk_object, $type_object, $fk_user);
27 | $token->fk_object = $fk_object;
28 | $token->type_object = $type_object;
29 | $token->fk_user = $fk_user;
30 | $token->to_sync = 0;
31 | $token->token =$tok->access_token;
32 | $token->refresh_token =$tok->refresh_token;
33 |
34 | $token->save($PDOdb);
35 | }
36 |
37 | $Tab = $PDOdb->ExecuteAsArray("SELECT * FROM ".MAIN_DB_PREFIX."zenfusion_contacts_records");
38 | //$Tab=array();
39 | // var_dump($Tab);
40 |
41 |
42 | foreach($Tab as &$row) {
43 | $fk_object = $row->id_record_dolibarr;
44 | $type_object = 'societe';
45 | $fk_user = $row->id_dolibarr_user;
46 |
47 | // TGCSToken::setSync($PDOdb, $object->id, $object->element, $user->id);
48 | $token = new TGCSToken;
49 |
50 | if(!empty($row->id_record_google) && !$token->loadByObject($PDOdb, $fk_object, $type_object, $fk_user)) {
51 | $token->fk_object = $fk_object;
52 | $token->type_object = $type_object;
53 | $token->fk_user = $fk_user;
54 | $token->to_sync = 0;
55 | $token->token =strtr( $row->id_record_google, array('http://'=>'https://', '/base/'=>'/full/'));
56 |
57 | $token->save($PDOdb);
58 | }
59 | }
60 |
61 |
62 | $Tab = $PDOdb->ExecuteAsArray("SELECT * FROM ".MAIN_DB_PREFIX."zenfusion_socpeople_records");
63 |
64 | foreach($Tab as &$row) {
65 | $fk_object = $row->id_record_dolibarr;
66 | $type_object = 'contact';
67 | $fk_user = $row->id_dolibarr_user;
68 |
69 | $token = new TGCSToken;
70 | if(!empty($row->id_record_google) && !$token->loadByObject($PDOdb, $fk_object, $type_object, $fk_user)) {
71 | $token->fk_object = $fk_object;
72 | $token->type_object = $type_object;
73 | $token->fk_user = $fk_user;
74 | $token->to_sync = 0;
75 | $token->token =strtr( $row->id_record_google, array('http://'=>'https://', '/base/'=>'/full/'));
76 |
77 | $token->save($PDOdb);
78 | }
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/ApiMediaFileUploadTest.php:
--------------------------------------------------------------------------------
1 | getClient();
26 | $request = new Google_Http_Request('http://www.example.com', 'POST');
27 | $media = new Google_Http_MediaFileUpload(
28 | $client,
29 | $request,
30 | 'image/png',
31 | base64_decode('data:image/png;base64,a')
32 | );
33 |
34 | $this->assertEquals(0, $media->getProgress());
35 | $this->assertGreaterThan(0, strlen($request->getPostBody()));
36 | }
37 |
38 | public function testGetUploadType()
39 | {
40 | $client = $this->getClient();
41 | $request = new Google_Http_Request('http://www.example.com', 'POST');
42 |
43 | // Test resumable upload
44 | $media = new Google_Http_MediaFileUpload($client, $request, 'image/png', 'a', true);
45 | $params = array('mediaUpload' => array('value' => $media));
46 | $this->assertEquals('resumable', $media->getUploadType(null));
47 |
48 | // Test data *only* uploads
49 | $media = new Google_Http_MediaFileUpload($client, $request, 'image/png', 'a', false);
50 | $this->assertEquals('media', $media->getUploadType(null));
51 |
52 | // Test multipart uploads
53 | $media = new Google_Http_MediaFileUpload($client, $request, 'image/png', 'a', false);
54 | $this->assertEquals('multipart', $media->getUploadType(array('a' => 'b')));
55 | }
56 |
57 | public function testResultCode()
58 | {
59 | $client = $this->getClient();
60 | $request = new Google_Http_Request('http://www.example.com', 'POST');
61 |
62 | // Test resumable upload
63 | $media = new Google_Http_MediaFileUpload($client, $request, 'image/png', 'a', true);
64 | $this->assertEquals(null, $media->getHttpResultCode());
65 | }
66 |
67 | public function testProcess()
68 | {
69 | $client = $this->getClient();
70 | $data = 'foo';
71 |
72 | // Test data *only* uploads.
73 | $request = new Google_Http_Request('http://www.example.com', 'POST');
74 | $media = new Google_Http_MediaFileUpload($client, $request, 'image/png', $data, false);
75 | $this->assertEquals($data, $request->getPostBody());
76 |
77 | // Test resumable (meta data) - we want to send the metadata, not the app data.
78 | $request = new Google_Http_Request('http://www.example.com', 'POST');
79 | $reqData = json_encode("hello");
80 | $request->setPostBody($reqData);
81 | $media = new Google_Http_MediaFileUpload($client, $request, 'image/png', $data, true);
82 | $this->assertEquals(json_decode($reqData), $request->getPostBody());
83 |
84 | // Test multipart - we are sending encoded meta data and post data
85 | $request = new Google_Http_Request('http://www.example.com', 'POST');
86 | $reqData = json_encode("hello");
87 | $request->setPostBody($reqData);
88 | $media = new Google_Http_MediaFileUpload($client, $request, 'image/png', $data, false);
89 | $this->assertContains($reqData, $request->getPostBody());
90 | $this->assertContains(base64_encode($data), $request->getPostBody());
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Service/GroupsMigration.php:
--------------------------------------------------------------------------------
1 |
20 | * Groups Migration Api.
21 | *
22 | *
23 | * For more information about this service, see the API
24 | * Documentation
25 | *
26 | *
27 | * @author Google, Inc.
28 | */
29 | class Google_Service_GroupsMigration extends Google_Service
30 | {
31 | /** Manage messages in groups on your domain. */
32 | const APPS_GROUPS_MIGRATION =
33 | "https://www.googleapis.com/auth/apps.groups.migration";
34 |
35 | public $archive;
36 |
37 |
38 | /**
39 | * Constructs the internal representation of the GroupsMigration service.
40 | *
41 | * @param Google_Client $client
42 | */
43 | public function __construct(Google_Client $client)
44 | {
45 | parent::__construct($client);
46 | $this->rootUrl = 'https://www.googleapis.com/';
47 | $this->servicePath = 'groups/v1/groups/';
48 | $this->version = 'v1';
49 | $this->serviceName = 'groupsmigration';
50 |
51 | $this->archive = new Google_Service_GroupsMigration_Archive_Resource(
52 | $this,
53 | $this->serviceName,
54 | 'archive',
55 | array(
56 | 'methods' => array(
57 | 'insert' => array(
58 | 'path' => '{groupId}/archive',
59 | 'httpMethod' => 'POST',
60 | 'parameters' => array(
61 | 'groupId' => array(
62 | 'location' => 'path',
63 | 'type' => 'string',
64 | 'required' => true,
65 | ),
66 | ),
67 | ),
68 | )
69 | )
70 | );
71 | }
72 | }
73 |
74 |
75 | /**
76 | * The "archive" collection of methods.
77 | * Typical usage is:
78 | *
79 | * $groupsmigrationService = new Google_Service_GroupsMigration(...);
80 | * $archive = $groupsmigrationService->archive;
81 | *
82 | */
83 | class Google_Service_GroupsMigration_Archive_Resource extends Google_Service_Resource
84 | {
85 |
86 | /**
87 | * Inserts a new mail into the archive of the Google group. (archive.insert)
88 | *
89 | * @param string $groupId The group ID
90 | * @param array $optParams Optional parameters.
91 | * @return Google_Service_GroupsMigration_Groups
92 | */
93 | public function insert($groupId, $optParams = array())
94 | {
95 | $params = array('groupId' => $groupId);
96 | $params = array_merge($params, $optParams);
97 | return $this->call('insert', array($params), "Google_Service_GroupsMigration_Groups");
98 | }
99 | }
100 |
101 |
102 |
103 |
104 | class Google_Service_GroupsMigration_Groups extends Google_Model
105 | {
106 | protected $internal_gapi_mappings = array(
107 | );
108 | public $kind;
109 | public $responseCode;
110 |
111 |
112 | public function setKind($kind)
113 | {
114 | $this->kind = $kind;
115 | }
116 | public function getKind()
117 | {
118 | return $this->kind;
119 | }
120 | public function setResponseCode($responseCode)
121 | {
122 | $this->responseCode = $responseCode;
123 | }
124 | public function getResponseCode()
125 | {
126 | return $this->responseCode;
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/examples/idtoken.php:
--------------------------------------------------------------------------------
1 | ';
28 | $client_secret = '';
29 | $redirect_uri = '';
30 |
31 | $client = new Google_Client();
32 | $client->setClientId($client_id);
33 | $client->setClientSecret($client_secret);
34 | $client->setRedirectUri($redirect_uri);
35 | $client->setScopes('email');
36 |
37 | /************************************************
38 | If we're logging out we just need to clear our
39 | local access token in this case
40 | ************************************************/
41 | if (isset($_REQUEST['logout'])) {
42 | unset($_SESSION['access_token']);
43 | }
44 |
45 | /************************************************
46 | If we have a code back from the OAuth 2.0 flow,
47 | we need to exchange that with the authenticate()
48 | function. We store the resultant access token
49 | bundle in the session, and redirect to ourself.
50 | ************************************************/
51 | if (isset($_GET['code'])) {
52 | $client->authenticate($_GET['code']);
53 | $_SESSION['access_token'] = $client->getAccessToken();
54 | $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
55 | header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
56 | }
57 |
58 | /************************************************
59 | If we have an access token, we can make
60 | requests, else we generate an authentication URL.
61 | ************************************************/
62 | if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
63 | $client->setAccessToken($_SESSION['access_token']);
64 | } else {
65 | $authUrl = $client->createAuthUrl();
66 | }
67 |
68 | /************************************************
69 | If we're signed in we can go ahead and retrieve
70 | the ID token, which is part of the bundle of
71 | data that is exchange in the authenticate step
72 | - we only need to do a network call if we have
73 | to retrieve the Google certificate to verify it,
74 | and that can be cached.
75 | ************************************************/
76 | if ($client->getAccessToken()) {
77 | $_SESSION['access_token'] = $client->getAccessToken();
78 | $token_data = $client->verifyIdToken()->getAttributes();
79 | }
80 |
81 | echo pageHeader("User Query - Retrieving An Id Token");
82 | if (strpos($client_id, "googleusercontent") == false) {
83 | echo missingClientSecretsWarning();
84 | exit;
85 | }
86 | ?>
87 |
88 |
89 | Connect Me!";
92 | } else {
93 | echo "
Logout ";
94 | }
95 | ?>
96 |
97 |
98 |
99 |
104 |
105 |
106 | client = $client;
42 | }
43 |
44 | /**
45 | * Retrieve an access token for the scopes supplied.
46 | */
47 | public function authenticateForScope($scopes)
48 | {
49 | if ($this->token && $this->tokenScopes == $scopes) {
50 | return $this->token;
51 | }
52 |
53 | $cacheKey = self::CACHE_PREFIX;
54 | if (is_string($scopes)) {
55 | $cacheKey .= $scopes;
56 | } else if (is_array($scopes)) {
57 | $cacheKey .= implode(":", $scopes);
58 | }
59 |
60 | $this->token = $this->client->getCache()->get($cacheKey);
61 | if (!$this->token) {
62 | $this->retrieveToken($scopes, $cacheKey);
63 | } else if ($this->token['expiration_time'] < time()) {
64 | $this->client->getCache()->delete($cacheKey);
65 | $this->retrieveToken($scopes, $cacheKey);
66 | }
67 |
68 | $this->tokenScopes = $scopes;
69 | return $this->token;
70 | }
71 |
72 | /**
73 | * Retrieve a new access token and store it in cache
74 | * @param mixed $scopes
75 | * @param string $cacheKey
76 | */
77 | private function retrieveToken($scopes, $cacheKey)
78 | {
79 | $this->token = AppIdentityService::getAccessToken($scopes);
80 | if ($this->token) {
81 | $this->client->getCache()->set(
82 | $cacheKey,
83 | $this->token
84 | );
85 | }
86 | }
87 |
88 | /**
89 | * Perform an authenticated / signed apiHttpRequest.
90 | * This function takes the apiHttpRequest, calls apiAuth->sign on it
91 | * (which can modify the request in what ever way fits the auth mechanism)
92 | * and then calls apiCurlIO::makeRequest on the signed request
93 | *
94 | * @param Google_Http_Request $request
95 | * @return Google_Http_Request The resulting HTTP response including the
96 | * responseHttpCode, responseHeaders and responseBody.
97 | */
98 | public function authenticatedRequest(Google_Http_Request $request)
99 | {
100 | $request = $this->sign($request);
101 | return $this->client->getIo()->makeRequest($request);
102 | }
103 |
104 | public function sign(Google_Http_Request $request)
105 | {
106 | if (!$this->token) {
107 | // No token, so nothing to do.
108 | return $request;
109 | }
110 |
111 | $this->client->getLogger()->debug('App Identity authentication');
112 |
113 | // Add the OAuth2 header to the request
114 | $request->setRequestHeaders(
115 | array('Authorization' => 'Bearer ' . $this->token['access_token'])
116 | );
117 |
118 | return $request;
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/examples/simplefileupload.php:
--------------------------------------------------------------------------------
1 | ';
39 | $client_secret = '';
40 | $redirect_uri = '';
41 |
42 | $client = new Google_Client();
43 | $client->setClientId($client_id);
44 | $client->setClientSecret($client_secret);
45 | $client->setRedirectUri($redirect_uri);
46 | $client->addScope("https://www.googleapis.com/auth/drive");
47 | $service = new Google_Service_Drive($client);
48 |
49 | if (isset($_REQUEST['logout'])) {
50 | unset($_SESSION['upload_token']);
51 | }
52 |
53 | if (isset($_GET['code'])) {
54 | $client->authenticate($_GET['code']);
55 | $_SESSION['upload_token'] = $client->getAccessToken();
56 | $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
57 | header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
58 | }
59 |
60 | if (isset($_SESSION['upload_token']) && $_SESSION['upload_token']) {
61 | $client->setAccessToken($_SESSION['upload_token']);
62 | if ($client->isAccessTokenExpired()) {
63 | unset($_SESSION['upload_token']);
64 | }
65 | } else {
66 | $authUrl = $client->createAuthUrl();
67 | }
68 |
69 | /************************************************
70 | If we're signed in then lets try to upload our
71 | file. For larger files, see fileupload.php.
72 | ************************************************/
73 | if ($client->getAccessToken()) {
74 | // This is uploading a file directly, with no metadata associated.
75 | $file = new Google_Service_Drive_DriveFile();
76 | $result = $service->files->insert(
77 | $file,
78 | array(
79 | 'data' => file_get_contents(TESTFILE),
80 | 'mimeType' => 'application/octet-stream',
81 | 'uploadType' => 'media'
82 | )
83 | );
84 |
85 | // Now lets try and send the metadata as well using multipart!
86 | $file = new Google_Service_Drive_DriveFile();
87 | $file->setTitle("Hello World!");
88 | $result2 = $service->files->insert(
89 | $file,
90 | array(
91 | 'data' => file_get_contents(TESTFILE),
92 | 'mimeType' => 'application/octet-stream',
93 | 'uploadType' => 'multipart'
94 | )
95 | );
96 | }
97 |
98 | echo pageHeader("File Upload - Uploading a small file");
99 | if (strpos($client_id, "googleusercontent") == false) {
100 | echo missingClientSecretsWarning();
101 | exit;
102 | }
103 | ?>
104 |
105 |
106 | Connect Me!";
109 | }
110 | ?>
111 |
112 |
113 |
114 | title);
117 | var_dump($result2->title);
118 | }
119 | ?>
120 |
121 |
122 | getClient();
27 | $client->setClassConfig(
28 | 'Google_Cache_File',
29 | 'directory',
30 | $dir
31 | );
32 | $cache = new Google_Cache_File($client);
33 | $cache->set('foo', 'bar');
34 | $this->assertEquals($cache->get('foo'), 'bar');
35 |
36 | $this->getSetDelete($cache);
37 | }
38 |
39 | /**
40 | * @requires extension Memcache
41 | */
42 | public function testNull()
43 | {
44 | $client = $this->getClient();
45 | $cache = new Google_Cache_Null($client);
46 | $client->setCache($cache);
47 |
48 | $cache->set('foo', 'bar');
49 | $cache->delete('foo');
50 | $this->assertEquals(false, $cache->get('foo'));
51 |
52 | $cache->set('foo.1', 'bar.1');
53 | $this->assertEquals($cache->get('foo.1'), false);
54 |
55 | $cache->set('foo', 'baz');
56 | $this->assertEquals($cache->get('foo'), false);
57 |
58 | $cache->set('foo', null);
59 | $cache->delete('foo');
60 | $this->assertEquals($cache->get('foo'), false);
61 | }
62 |
63 | /**
64 | * @requires extension Memcache
65 | */
66 | public function testMemcache()
67 | {
68 | $client = $this->getClient();
69 | if (!$client->getClassConfig('Google_Cache_Memcache', 'host')) {
70 | $this->markTestSkipped('Test requires memcache host specified');
71 | }
72 |
73 | $cache = new Google_Cache_Memcache($client);
74 |
75 | $this->getSetDelete($cache);
76 | }
77 |
78 | /**
79 | * @requires extension APC
80 | */
81 | public function testAPC()
82 | {
83 | if (!ini_get('apc.enable_cli')) {
84 | $this->markTestSkipped('Test requires APC enabled for CLI');
85 | }
86 | $client = $this->getClient();
87 | $cache = new Google_Cache_Apc($client);
88 |
89 | $this->getSetDelete($cache);
90 | }
91 |
92 | public function getSetDelete($cache)
93 | {
94 | $cache->set('foo', 'bar');
95 | $cache->delete('foo');
96 | $this->assertEquals(false, $cache->get('foo'));
97 |
98 | $cache->set('foo.1', 'bar.1');
99 | $cache->delete('foo.1');
100 | $this->assertEquals($cache->get('foo.1'), false);
101 |
102 | $cache->set('foo', 'baz');
103 | $cache->delete('foo');
104 | $this->assertEquals($cache->get('foo'), false);
105 |
106 | $cache->set('foo', null);
107 | $cache->delete('foo');
108 | $this->assertEquals($cache->get('foo'), false);
109 |
110 | $obj = new stdClass();
111 | $obj->foo = 'bar';
112 | $cache->set('foo', $obj);
113 | $cache->delete('foo');
114 | $this->assertEquals($cache->get('foo'), false);
115 |
116 | $cache->set('foo.1', 'bar.1');
117 | $this->assertEquals($cache->get('foo.1'), 'bar.1');
118 |
119 | $cache->set('foo', 'baz');
120 | $this->assertEquals($cache->get('foo'), 'baz');
121 |
122 | $cache->set('foo', null);
123 | $this->assertEquals($cache->get('foo'), null);
124 |
125 | $cache->set('1/2/3', 'bar');
126 | $this->assertEquals($cache->get('1/2/3'), 'bar');
127 |
128 | $obj = new stdClass();
129 | $obj->foo = 'bar';
130 | $cache->set('foo', $obj);
131 | $this->assertEquals($cache->get('foo'), $obj);
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/script/interface.php:
--------------------------------------------------------------------------------
1 | modules_parts['triggers']=array();// Ouh que c'est moche mais sinon le trigger de dropcloud passe foutre le merdier
8 |
9 | $put = GETPOST('put');
10 | $get = GETPOST('get');
11 |
12 | $_SESSION['GCS_fk_user'] = $user->id;
13 |
14 | switch ($put) {
15 | case 'sync':
16 |
17 | __out(_sync(GETPOST('nb')),'json');
18 |
19 | break;
20 |
21 | case 'optimizedSync':
22 |
23 | __out(_optimizedSync(),'json');
24 |
25 | break;
26 |
27 | case 'setGroup':
28 |
29 | __out(_setGroup(GETPOST('name')),'json');
30 |
31 | break;
32 | case 'deleteAllGroups':
33 | require_once __DIR__.'/../php-google-contacts-v3-api/vendor/autoload.php';
34 | rapidweb\googlecontacts\factories\ContactFactory::deleteAllGroups('https://www.google.com/m8/feeds/groups/'.urlencode($user->email).'/full');
35 |
36 |
37 | break;
38 | }
39 |
40 | switch($get) {
41 | case 'all-contact':
42 | __out(_getAllContact(),'json');
43 | break;
44 | }
45 |
46 |
47 | function _setGroup($name) {
48 | global $user;
49 |
50 | $PDOdb=new \TPDOdb;
51 |
52 | require_once __DIR__.'/../php-google-contacts-v3-api/vendor/autoload.php';
53 |
54 | return \TGCSToken::setGroup($user,$name);
55 |
56 | }
57 |
58 | function _sync($nb=5) {
59 | global $user,$fk_user_gcs;
60 | $PDOdb=new \TPDOdb;
61 | if(empty($nb))$nb = 5;
62 | $TToken = \TGCSToken::getTokenToSync($PDOdb,$user->id,$nb);
63 |
64 | $TSync=array();
65 | foreach($TToken as &$token) {
66 | $res = $token->sync($PDOdb);
67 | $token->to_sync = 0;
68 | // Desactivé pour éviter appel infini
69 | /*if($res === false) {
70 | $token->to_sync = 1;
71 | $token->save($PDOdb);
72 | }
73 | else{*/
74 | $token->save($PDOdb);
75 | $TSync[] = $token;
76 | //}
77 | }
78 |
79 | return $TSync;
80 | }
81 |
82 | function _optimizedSync() {
83 | global $user,$fk_user_gcs;
84 |
85 | require_once __DIR__.'/../php-google-contacts-v3-api/vendor/autoload.php';
86 |
87 | $PDOdb=new \TPDOdb;
88 |
89 | $TToken = \TGCSToken::getTokenToSync($PDOdb,$user->id);
90 |
91 | $TSync = array();
92 |
93 | $apiBaseURL = 'https://www.google.com/m8/feeds/contacts/'.urlencode($user->email).'/thin';
94 |
95 | $contacts = rapidweb\googlecontacts\factories\ContactFactory::getAll();
96 |
97 | if(!empty($conf->global->GCS_GOOGLE_GROUP_NAME)) {
98 | $contactGroup = \TGCSToken::setGroup($user, $conf->global->GCS_GOOGLE_GROUP_NAME);
99 | // $contact->groupMembershipInfo = $contactGroup->id;
100 | }
101 |
102 | /*
103 | echo '';
104 | var_dump($contacts);
105 | echo ' ';
106 |
107 | echo '';
108 | var_dump($TToken);
109 | echo ' ';
110 | */
111 |
112 | if (! empty($contacts))
113 | {
114 | $contactKeys = array();
115 | foreach($contacts as $contact) {
116 | $contactID = $contact->id;
117 | // echo $contactID, " ";
118 | $contactKeys[] = substr($contactID, strrpos($contactID, '/') + 1);
119 | }
120 | /*
121 | echo '';
122 | var_dump($contactKeys);
123 | echo ' ';
124 | */
125 | foreach($TToken as $token) {
126 | /*
127 | echo '';
128 | var_dump($token->token);
129 | echo ' ';
130 | */
131 | $tok = $token->token;
132 |
133 | $index = array_search(substr($tok, strrpos($tok, '/') + 1), $contactKeys);
134 |
135 | if($index >= 0)
136 | {
137 | // echo "Trouvé contact ".$token->token." ";
138 | // $token->contact = new rapidweb\googlecontacts\objects\Contact($contacts[$index]);
139 | $token->contact = $contacts[$index];
140 | }
141 |
142 | if(!empty($conf->global->GCS_GOOGLE_GROUP_NAME)) {
143 | $token->contact->groupMembershipInfo = $contactGroup->id;
144 | }
145 |
146 | $res = $token->optimizedSync($PDOdb);
147 | $token->to_sync = 0;
148 | // Desactivé pour éviter appel infini
149 | /*if($res === false) {
150 | $token->to_sync = 1;
151 | $token->save($PDOdb);
152 | }
153 | else{*/
154 | $token->save($PDOdb);
155 | $TSync[] = $token;
156 | //}
157 | }
158 | }
159 |
160 | return $TSync;
161 | }
162 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/examples/multi-api.php:
--------------------------------------------------------------------------------
1 | ';
28 | $client_secret = '';
29 | $redirect_uri = '';
30 |
31 | /************************************************
32 | Make an API request on behalf of a user. In
33 | this case we need to have a valid OAuth 2.0
34 | token for the user, so we need to send them
35 | through a login flow. To do this we need some
36 | information from our API console project.
37 | ************************************************/
38 | $client = new Google_Client();
39 | $client->setClientId($client_id);
40 | $client->setClientSecret($client_secret);
41 | $client->setRedirectUri($redirect_uri);
42 | $client->addScope("https://www.googleapis.com/auth/drive");
43 | $client->addScope("https://www.googleapis.com/auth/youtube");
44 |
45 | /************************************************
46 | We are going to create both YouTube and Drive
47 | services, and query both.
48 | ************************************************/
49 | $yt_service = new Google_Service_YouTube($client);
50 | $dr_service = new Google_Service_Drive($client);
51 |
52 |
53 | /************************************************
54 | Boilerplate auth management - see
55 | user-example.php for details.
56 | ************************************************/
57 | if (isset($_REQUEST['logout'])) {
58 | unset($_SESSION['access_token']);
59 | }
60 | if (isset($_GET['code'])) {
61 | $client->authenticate($_GET['code']);
62 | $_SESSION['access_token'] = $client->getAccessToken();
63 | $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
64 | header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
65 | }
66 |
67 | if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
68 | $client->setAccessToken($_SESSION['access_token']);
69 | } else {
70 | $authUrl = $client->createAuthUrl();
71 | }
72 |
73 | /************************************************
74 | If we're signed in, retrieve channels from YouTube
75 | and a list of files from Drive.
76 | ************************************************/
77 | if ($client->getAccessToken()) {
78 | $_SESSION['access_token'] = $client->getAccessToken();
79 |
80 | $dr_results = $dr_service->files->listFiles(array('maxResults' => 10));
81 |
82 | $yt_channels = $yt_service->channels->listChannels('contentDetails', array("mine" => true));
83 | $likePlaylist = $yt_channels[0]->contentDetails->relatedPlaylists->likes;
84 | $yt_results = $yt_service->playlistItems->listPlaylistItems(
85 | "snippet",
86 | array("playlistId" => $likePlaylist)
87 | );
88 | }
89 |
90 | echo pageHeader("User Query - Multiple APIs");
91 | if (strpos($client_id, "googleusercontent") == false) {
92 | echo missingClientSecretsWarning();
93 | exit;
94 | }
95 | ?>
96 |
97 |
98 | Connect Me!";
101 | } else {
102 | echo "
Results Of Drive List: ";
103 | foreach ($dr_results as $item) {
104 | echo $item->title, " \n";
105 | }
106 |
107 | echo "Results Of YouTube Likes: ";
108 | foreach ($yt_results as $item) {
109 | echo $item['snippet']['title'], " \n";
110 | }
111 | } ?>
112 |
113 |
114 | getClassConfig('Google_Logger_File', 'file');
59 | if (!is_string($file) && !is_resource($file)) {
60 | throw new Google_Logger_Exception(
61 | 'File logger requires a filename or a valid file pointer'
62 | );
63 | }
64 |
65 | $mode = $client->getClassConfig('Google_Logger_File', 'mode');
66 | if (!$mode) {
67 | $this->mode = $mode;
68 | }
69 |
70 | $this->lock = (bool) $client->getClassConfig('Google_Logger_File', 'lock');
71 | $this->file = $file;
72 | }
73 |
74 | /**
75 | * {@inheritdoc}
76 | */
77 | protected function write($message)
78 | {
79 | if (is_string($this->file)) {
80 | $this->open();
81 | } elseif (!is_resource($this->file)) {
82 | throw new Google_Logger_Exception('File pointer is no longer available');
83 | }
84 |
85 | if ($this->lock) {
86 | flock($this->file, LOCK_EX);
87 | }
88 |
89 | fwrite($this->file, (string) $message);
90 |
91 | if ($this->lock) {
92 | flock($this->file, LOCK_UN);
93 | }
94 | }
95 |
96 | /**
97 | * Opens the log for writing.
98 | *
99 | * @return resource
100 | */
101 | private function open()
102 | {
103 | // Used for trapping `fopen()` errors.
104 | $this->trappedErrorNumber = null;
105 | $this->trappedErrorString = null;
106 |
107 | $old = set_error_handler(array($this, 'trapError'));
108 |
109 | $needsChmod = !file_exists($this->file);
110 | $fh = fopen($this->file, 'a');
111 |
112 | restore_error_handler();
113 |
114 | // Handles trapped `fopen()` errors.
115 | if ($this->trappedErrorNumber) {
116 | throw new Google_Logger_Exception(
117 | sprintf(
118 | "Logger Error: '%s'",
119 | $this->trappedErrorString
120 | ),
121 | $this->trappedErrorNumber
122 | );
123 | }
124 |
125 | if ($needsChmod) {
126 | @chmod($this->file, $this->mode & ~umask());
127 | }
128 |
129 | return $this->file = $fh;
130 | }
131 |
132 | /**
133 | * Closes the log stream resource.
134 | */
135 | private function close()
136 | {
137 | if (is_resource($this->file)) {
138 | fclose($this->file);
139 | }
140 | }
141 |
142 | /**
143 | * Traps `fopen()` errors.
144 | *
145 | * @param integer $errno The error number
146 | * @param string $errstr The error string
147 | */
148 | private function trapError($errno, $errstr)
149 | {
150 | $this->trappedErrorNumber = $errno;
151 | $this->trappedErrorString = $errstr;
152 | }
153 |
154 | public function __destruct()
155 | {
156 | $this->close();
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Auth/AssertionCredentials.php:
--------------------------------------------------------------------------------
1 | serviceAccountName = $serviceAccountName;
63 | $this->scopes = is_string($scopes) ? $scopes : implode(' ', $scopes);
64 | $this->privateKey = $privateKey;
65 | $this->privateKeyPassword = $privateKeyPassword;
66 | $this->assertionType = $assertionType;
67 | $this->sub = $sub;
68 | $this->prn = $sub;
69 | $this->useCache = $useCache;
70 | }
71 |
72 | /**
73 | * Generate a unique key to represent this credential.
74 | * @return string
75 | */
76 | public function getCacheKey()
77 | {
78 | if (!$this->useCache) {
79 | return false;
80 | }
81 | $h = $this->sub;
82 | $h .= $this->assertionType;
83 | $h .= $this->privateKey;
84 | $h .= $this->scopes;
85 | $h .= $this->serviceAccountName;
86 | return md5($h);
87 | }
88 |
89 | public function generateAssertion()
90 | {
91 | $now = time();
92 |
93 | $jwtParams = array(
94 | 'aud' => Google_Auth_OAuth2::OAUTH2_TOKEN_URI,
95 | 'scope' => $this->scopes,
96 | 'iat' => $now,
97 | 'exp' => $now + self::MAX_TOKEN_LIFETIME_SECS,
98 | 'iss' => $this->serviceAccountName,
99 | );
100 |
101 | if ($this->sub !== false) {
102 | $jwtParams['sub'] = $this->sub;
103 | } else if ($this->prn !== false) {
104 | $jwtParams['prn'] = $this->prn;
105 | }
106 |
107 | return $this->makeSignedJwt($jwtParams);
108 | }
109 |
110 | /**
111 | * Creates a signed JWT.
112 | * @param array $payload
113 | * @return string The signed JWT.
114 | */
115 | private function makeSignedJwt($payload)
116 | {
117 | $header = array('typ' => 'JWT', 'alg' => 'RS256');
118 |
119 | $payload = json_encode($payload);
120 | // Handle some overzealous escaping in PHP json that seemed to cause some errors
121 | // with claimsets.
122 | $payload = str_replace('\/', '/', $payload);
123 |
124 | $segments = array(
125 | Google_Utils::urlSafeB64Encode(json_encode($header)),
126 | Google_Utils::urlSafeB64Encode($payload)
127 | );
128 |
129 | $signingInput = implode('.', $segments);
130 | $signer = new Google_Signer_P12($this->privateKey, $this->privateKeyPassword);
131 | $signature = $signer->sign($signingInput);
132 | $segments[] = Google_Utils::urlSafeB64Encode($signature);
133 |
134 | return implode(".", $segments);
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Utils.php:
--------------------------------------------------------------------------------
1 | = 0x20) && ($ordinalValue <= 0x7F)):
68 | // characters U-00000000 - U-0000007F (same as ASCII)
69 | $ret ++;
70 | break;
71 | case (($ordinalValue & 0xE0) == 0xC0):
72 | // characters U-00000080 - U-000007FF, mask 110XXXXX
73 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
74 | $ret += 2;
75 | break;
76 | case (($ordinalValue & 0xF0) == 0xE0):
77 | // characters U-00000800 - U-0000FFFF, mask 1110XXXX
78 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
79 | $ret += 3;
80 | break;
81 | case (($ordinalValue & 0xF8) == 0xF0):
82 | // characters U-00010000 - U-001FFFFF, mask 11110XXX
83 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
84 | $ret += 4;
85 | break;
86 | case (($ordinalValue & 0xFC) == 0xF8):
87 | // characters U-00200000 - U-03FFFFFF, mask 111110XX
88 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
89 | $ret += 5;
90 | break;
91 | case (($ordinalValue & 0xFE) == 0xFC):
92 | // characters U-04000000 - U-7FFFFFFF, mask 1111110X
93 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
94 | $ret += 6;
95 | break;
96 | default:
97 | $ret ++;
98 | }
99 | }
100 | return $ret;
101 | }
102 |
103 | /**
104 | * Normalize all keys in an array to lower-case.
105 | * @param array $arr
106 | * @return array Normalized array.
107 | */
108 | public static function normalize($arr)
109 | {
110 | if (!is_array($arr)) {
111 | return array();
112 | }
113 |
114 | $normalized = array();
115 | foreach ($arr as $key => $val) {
116 | $normalized[strtolower($key)] = $val;
117 | }
118 | return $normalized;
119 | }
120 |
121 | /**
122 | * Convert a string to camelCase
123 | * @param string $value
124 | * @return string
125 | */
126 | public static function camelCase($value)
127 | {
128 | $value = ucwords(str_replace(array('-', '_'), ' ', $value));
129 | $value = str_replace(' ', '', $value);
130 | $value[0] = strtolower($value[0]);
131 | return $value;
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/Http/BatchTest.php:
--------------------------------------------------------------------------------
1 | client = $this->getMockBuilder("Google_Client")
24 | ->disableOriginalConstructor()
25 | ->getMock();
26 | }
27 |
28 | public function testBasicFunctionality()
29 | {
30 | $this->client->expects($this->once())
31 | ->method("getBasePath")
32 | ->will($this->returnValue("base_path"));
33 | $batch = new Google_Http_Batch($this->client);
34 | $this->assertAttributeEquals("base_path", "root_url", $batch);
35 | $this->assertAttributeEquals("batch", "batch_path", $batch);
36 | }
37 |
38 | public function testExtractionOfRootUrlFromService()
39 | {
40 | $this->client->expects($this->never())
41 | ->method("getBasePath");
42 | $service = new Google_Service($this->client);
43 | $service->rootUrl = "root_url_dummy";
44 | $service->batchPath = "batch_path_dummy";
45 | $batch = $service->createBatch();
46 | $this->assertInstanceOf("Google_Http_Batch", $batch);
47 | $this->assertAttributeEquals("root_url_dummy", "root_url", $batch);
48 | $this->assertAttributeEquals("batch_path_dummy", "batch_path", $batch);
49 | }
50 |
51 | public function testExecuteCustomRootUrlBatchPath()
52 | {
53 | $io = $this->getMockBuilder('Google_IO_Abstract')
54 | ->disableOriginalConstructor()
55 | ->setMethods(array('makeRequest', 'needsQuirk', 'executeRequest', 'setOptions', 'setTimeout', 'getTimeout'))
56 | ->getMock();
57 | $req = null;
58 | $io->expects($this->once())
59 | ->method("makeRequest")
60 | ->will($this->returnCallback(function($request) use (&$req) {
61 | $req = $request;
62 | return $request;
63 | }));
64 | $this->client->expects($this->once())
65 | ->method("getIo")
66 | ->will($this->returnValue($io));
67 | $batch = new Google_Http_Batch($this->client, false, 'https://www.example.com/', 'bat');
68 | $this->assertNull($batch->execute());
69 | $this->assertInstanceOf("Google_Http_Request", $req);
70 | $this->assertEquals("https://www.example.com/bat", $req->getUrl());
71 | }
72 |
73 | public function testExecuteBodySerialization()
74 | {
75 | $io = $this->getMockBuilder('Google_IO_Abstract')
76 | ->disableOriginalConstructor()
77 | ->setMethods(array('makeRequest', 'needsQuirk', 'executeRequest', 'setOptions', 'setTimeout', 'getTimeout'))
78 | ->getMock();
79 | $req = null;
80 | $io->expects($this->once())
81 | ->method("makeRequest")
82 | ->will($this->returnCallback(function($request) use (&$req) {
83 | $req = $request;
84 | return $request;
85 | }));
86 | $this->client->expects($this->once())
87 | ->method("getIo")
88 | ->will($this->returnValue($io));
89 | $batch = new Google_Http_Batch($this->client, "BOUNDARY_TEXT", 'https://www.example.com/', 'bat');
90 | $req1 = new Google_Http_Request("https://www.example.com/req1");
91 | $req2 = new Google_Http_Request("https://www.example.com/req2", 'POST', array(), 'POSTBODY');
92 | $batch->add($req1, '1');
93 | $batch->add($req2, '2');
94 | $this->assertNull($batch->execute());
95 | $this->assertInstanceOf("Google_Http_Request", $req);
96 | $format = <<<'EOF'
97 | --BOUNDARY_TEXT
98 | Content-Type: application/http
99 | Content-Transfer-Encoding: binary
100 | MIME-Version: 1.0
101 | Content-ID: 1
102 |
103 | GET /req1? HTTP/1.1
104 |
105 |
106 | --BOUNDARY_TEXT
107 | Content-Type: application/http
108 | Content-Transfer-Encoding: binary
109 | MIME-Version: 1.0
110 | Content-ID: 2
111 |
112 | POST /req2? HTTP/1.1
113 |
114 | POSTBODY
115 |
116 | --BOUNDARY_TEXT--
117 | EOF;
118 | $this->assertEquals($format, $req->getPostBody());
119 | }
120 |
121 | }
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Auth/ComputeEngine.php:
--------------------------------------------------------------------------------
1 |
27 | */
28 | class Google_Auth_ComputeEngine extends Google_Auth_Abstract
29 | {
30 | const METADATA_AUTH_URL =
31 | 'http://metadata/computeMetadata/v1/instance/service-accounts/default/token';
32 | private $client;
33 | private $token;
34 |
35 | public function __construct(Google_Client $client, $config = null)
36 | {
37 | $this->client = $client;
38 | }
39 |
40 | /**
41 | * Perform an authenticated / signed apiHttpRequest.
42 | * This function takes the apiHttpRequest, calls apiAuth->sign on it
43 | * (which can modify the request in what ever way fits the auth mechanism)
44 | * and then calls apiCurlIO::makeRequest on the signed request
45 | *
46 | * @param Google_Http_Request $request
47 | * @return Google_Http_Request The resulting HTTP response including the
48 | * responseHttpCode, responseHeaders and responseBody.
49 | */
50 | public function authenticatedRequest(Google_Http_Request $request)
51 | {
52 | $request = $this->sign($request);
53 | return $this->client->getIo()->makeRequest($request);
54 | }
55 |
56 | /**
57 | * @param string $token
58 | * @throws Google_Auth_Exception
59 | */
60 | public function setAccessToken($token)
61 | {
62 | $token = json_decode($token, true);
63 | if ($token == null) {
64 | throw new Google_Auth_Exception('Could not json decode the token');
65 | }
66 | if (! isset($token['access_token'])) {
67 | throw new Google_Auth_Exception("Invalid token format");
68 | }
69 | $token['created'] = time();
70 | $this->token = $token;
71 | }
72 |
73 | public function getAccessToken()
74 | {
75 | return json_encode($this->token);
76 | }
77 |
78 | /**
79 | * Acquires a new access token from the compute engine metadata server.
80 | * @throws Google_Auth_Exception
81 | */
82 | public function acquireAccessToken()
83 | {
84 | $request = new Google_Http_Request(
85 | self::METADATA_AUTH_URL,
86 | 'GET',
87 | array(
88 | 'Metadata-Flavor' => 'Google'
89 | )
90 | );
91 | $request->disableGzip();
92 | $response = $this->client->getIo()->makeRequest($request);
93 |
94 | if ($response->getResponseHttpCode() == 200) {
95 | $this->setAccessToken($response->getResponseBody());
96 | $this->token['created'] = time();
97 | return $this->getAccessToken();
98 | } else {
99 | throw new Google_Auth_Exception(
100 | sprintf(
101 | "Error fetching service account access token, message: '%s'",
102 | $response->getResponseBody()
103 | ),
104 | $response->getResponseHttpCode()
105 | );
106 | }
107 | }
108 |
109 | /**
110 | * Include an accessToken in a given apiHttpRequest.
111 | * @param Google_Http_Request $request
112 | * @return Google_Http_Request
113 | * @throws Google_Auth_Exception
114 | */
115 | public function sign(Google_Http_Request $request)
116 | {
117 | if ($this->isAccessTokenExpired()) {
118 | $this->acquireAccessToken();
119 | }
120 |
121 | $this->client->getLogger()->debug('Compute engine service account authentication');
122 |
123 | $request->setRequestHeaders(
124 | array('Authorization' => 'Bearer ' . $this->token['access_token'])
125 | );
126 |
127 | return $request;
128 | }
129 |
130 | /**
131 | * Returns if the access_token is expired.
132 | * @return bool Returns True if the access_token is expired.
133 | */
134 | public function isAccessTokenExpired()
135 | {
136 | if (!$this->token || !isset($this->token['created'])) {
137 | return true;
138 | }
139 |
140 | // If the token is set to expire in the next 30 seconds.
141 | $expired = ($this->token['created']
142 | + ($this->token['expires_in'] - 30)) < time();
143 |
144 | return $expired;
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/tests/general/ResourceTest.php:
--------------------------------------------------------------------------------
1 | rootUrl = "";
27 | $this->servicePath = "";
28 | $this->version = "v1beta1";
29 | $this->serviceName = "test";
30 | }
31 | }
32 |
33 | class ResourceTest extends PHPUnit_Framework_TestCase
34 | {
35 | private $client;
36 | private $service;
37 | private $logger;
38 |
39 | public function setUp()
40 | {
41 | $this->client = $this->getMockBuilder("Google_Client")
42 | ->disableOriginalConstructor()
43 | ->getMock();
44 | $this->logger = $this->getMockBuilder("Google_Logger_Null")
45 | ->disableOriginalConstructor()
46 | ->getMock();
47 | $this->client->expects($this->any())
48 | ->method("getClassConfig")
49 | ->will($this->returnCallback(function($class, $type) {
50 | if (!is_string($class)) {
51 | $class = get_class($class);
52 | }
53 | $configMap = array(
54 | "Google_Auth_Simple" => array(
55 | "developer_key" => "testKey"
56 | ),
57 | );
58 | return isset($configMap[$class][$type]) ? $configMap[$class][$type] : null;
59 | }));
60 | $this->client->expects($this->any())
61 | ->method("getLogger")
62 | ->will($this->returnValue($this->logger));
63 | $this->client->expects($this->any())
64 | ->method("shouldDefer")
65 | ->will($this->returnValue(true));
66 | $this->client->expects($this->any())
67 | ->method("getBasePath")
68 | ->will($this->returnValue("https://test.example.com"));
69 | $this->client->expects($this->any())
70 | ->method("getAuth")
71 | ->will($this->returnValue(new Google_Auth_Simple($this->client)));
72 | $this->service = new Test_Google_Service($this->client);
73 | }
74 |
75 | public function testCallFailure()
76 | {
77 | $resource = new Google_Service_Resource(
78 | $this->service,
79 | "test",
80 | "testResource",
81 | array("methods" =>
82 | array(
83 | "testMethod" => array(
84 | "parameters" => array(),
85 | "path" => "method/path",
86 | "httpMethod" => "POST",
87 | )
88 | )
89 | )
90 | );
91 | $this->setExpectedException(
92 | "Google_Exception",
93 | "Unknown function: test->testResource->someothermethod()"
94 | );
95 | $resource->call("someothermethod", array());
96 | }
97 |
98 | public function testCallSimple()
99 | {
100 | $resource = new Google_Service_Resource(
101 | $this->service,
102 | "test",
103 | "testResource",
104 | array("methods" =>
105 | array(
106 | "testMethod" => array(
107 | "parameters" => array(),
108 | "path" => "method/path",
109 | "httpMethod" => "POST",
110 | )
111 | )
112 | )
113 | );
114 | $request = $resource->call("testMethod", array(array()));
115 | $this->assertEquals("https://test.example.com/method/path?key=testKey", $request->getUrl());
116 | $this->assertEquals("POST", $request->getRequestMethod());
117 | }
118 |
119 | public function testCallServiceDefinedRoot()
120 | {
121 | $this->service->rootUrl = "https://sample.example.com";
122 | $resource = new Google_Service_Resource(
123 | $this->service,
124 | "test",
125 | "testResource",
126 | array("methods" =>
127 | array(
128 | "testMethod" => array(
129 | "parameters" => array(),
130 | "path" => "method/path",
131 | "httpMethod" => "POST",
132 | )
133 | )
134 | )
135 | );
136 | $request = $resource->call("testMethod", array(array()));
137 | $this->assertEquals("https://sample.example.com/method/path?key=testKey", $request->getUrl());
138 | $this->assertEquals("POST", $request->getRequestMethod());
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/php-google-contacts-v3-api/vendor/google/apiclient/src/Google/Http/Batch.php:
--------------------------------------------------------------------------------
1 | client = $client;
45 | $this->root_url = rtrim($rootUrl ? $rootUrl : $this->client->getBasePath(), '/');
46 | $this->batch_path = $batchPath ? $batchPath : 'batch';
47 | $this->expected_classes = array();
48 | $boundary = (false == $boundary) ? mt_rand() : $boundary;
49 | $this->boundary = str_replace('"', '', $boundary);
50 | }
51 |
52 | public function add(Google_Http_Request $request, $key = false)
53 | {
54 | if (false == $key) {
55 | $key = mt_rand();
56 | }
57 |
58 | $this->requests[$key] = $request;
59 | }
60 |
61 | public function execute()
62 | {
63 | $body = '';
64 |
65 | /** @var Google_Http_Request $req */
66 | foreach ($this->requests as $key => $req) {
67 | $body .= "--{$this->boundary}\n";
68 | $body .= $req->toBatchString($key) . "\n\n";
69 | $this->expected_classes["response-" . $key] = $req->getExpectedClass();
70 | }
71 |
72 | $body .= "--{$this->boundary}--";
73 |
74 | $url = $this->root_url . '/' . $this->batch_path;
75 | $httpRequest = new Google_Http_Request($url, 'POST');
76 | $httpRequest->setRequestHeaders(
77 | array('Content-Type' => 'multipart/mixed; boundary=' . $this->boundary)
78 | );
79 |
80 | $httpRequest->setPostBody($body);
81 | $response = $this->client->getIo()->makeRequest($httpRequest);
82 |
83 | return $this->parseResponse($response);
84 | }
85 |
86 | public function parseResponse(Google_Http_Request $response)
87 | {
88 | $contentType = $response->getResponseHeader('content-type');
89 | $contentType = explode(';', $contentType);
90 | $boundary = false;
91 | foreach ($contentType as $part) {
92 | $part = (explode('=', $part, 2));
93 | if (isset($part[0]) && 'boundary' == trim($part[0])) {
94 | $boundary = $part[1];
95 | }
96 | }
97 |
98 | $body = $response->getResponseBody();
99 | if ($body) {
100 | $body = str_replace("--$boundary--", "--$boundary", $body);
101 | $parts = explode("--$boundary", $body);
102 | $responses = array();
103 |
104 | foreach ($parts as $part) {
105 | $part = trim($part);
106 | if (!empty($part)) {
107 | list($metaHeaders, $part) = explode("\r\n\r\n", $part, 2);
108 | $metaHeaders = $this->client->getIo()->getHttpResponseHeaders($metaHeaders);
109 |
110 | $status = substr($part, 0, strpos($part, "\n"));
111 | $status = explode(" ", $status);
112 | $status = $status[1];
113 |
114 | list($partHeaders, $partBody) = $this->client->getIo()->ParseHttpResponse($part, false);
115 | $response = new Google_Http_Request("");
116 | $response->setResponseHttpCode($status);
117 | $response->setResponseHeaders($partHeaders);
118 | $response->setResponseBody($partBody);
119 |
120 | // Need content id.
121 | $key = $metaHeaders['content-id'];
122 |
123 | if (isset($this->expected_classes[$key]) &&
124 | strlen($this->expected_classes[$key]) > 0) {
125 | $class = $this->expected_classes[$key];
126 | $response->setExpectedClass($class);
127 | }
128 |
129 | try {
130 | $response = Google_Http_REST::decodeHttpResponse($response, $this->client);
131 | $responses[$key] = $response;
132 | } catch (Google_Service_Exception $e) {
133 | // Store the exception as the response, so successful responses
134 | // can be processed.
135 | $responses[$key] = $e;
136 | }
137 | }
138 | }
139 |
140 | return $responses;
141 | }
142 |
143 | return null;
144 | }
145 | }
146 |
--------------------------------------------------------------------------------