├── .gitattributes
├── README.md
├── google-api-php-client
├── .gitignore
├── .travis.yml
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── autoload.php
├── composer.json
├── examples
│ ├── appengineauth.php
│ ├── batch.php
│ ├── fileupload.php
│ ├── idtoken.php
│ ├── index.php
│ ├── multi-api.php
│ ├── service-account.php
│ ├── simple-query.php
│ ├── simplefileupload.php
│ ├── styles
│ │ └── style.css
│ ├── templates
│ │ └── base.php
│ └── user-example.php
├── phpunit.xml.dist
├── src
│ └── Google
│ │ ├── Auth
│ │ ├── Abstract.php
│ │ ├── AppIdentity.php
│ │ ├── AssertionCredentials.php
│ │ ├── Exception.php
│ │ ├── LoginTicket.php
│ │ ├── OAuth2.php
│ │ └── Simple.php
│ │ ├── Cache
│ │ ├── Abstract.php
│ │ ├── Apc.php
│ │ ├── Exception.php
│ │ ├── File.php
│ │ ├── Memcache.php
│ │ └── Null.php
│ │ ├── Client.php
│ │ ├── Collection.php
│ │ ├── Config.php
│ │ ├── Exception.php
│ │ ├── Http
│ │ ├── Batch.php
│ │ ├── CacheParser.php
│ │ ├── MediaFileUpload.php
│ │ ├── REST.php
│ │ └── Request.php
│ │ ├── IO
│ │ ├── Abstract.php
│ │ ├── Curl.php
│ │ ├── Exception.php
│ │ ├── Stream.php
│ │ └── cacerts.pem
│ │ ├── Logger
│ │ ├── Abstract.php
│ │ ├── Exception.php
│ │ ├── File.php
│ │ ├── Null.php
│ │ └── Psr.php
│ │ ├── Model.php
│ │ ├── Service.php
│ │ ├── Service
│ │ ├── AdExchangeBuyer.php
│ │ ├── AdExchangeSeller.php
│ │ ├── AdSense.php
│ │ ├── AdSenseHost.php
│ │ ├── Admin.php
│ │ ├── Analytics.php
│ │ ├── AndroidPublisher.php
│ │ ├── AppState.php
│ │ ├── Appsactivity.php
│ │ ├── Audit.php
│ │ ├── Autoscaler.php
│ │ ├── Bigquery.php
│ │ ├── Blogger.php
│ │ ├── Books.php
│ │ ├── Calendar.php
│ │ ├── CivicInfo.php
│ │ ├── CloudMonitoring.php
│ │ ├── Cloudlatencytest.php
│ │ ├── Compute.php
│ │ ├── Container.php
│ │ ├── Coordinate.php
│ │ ├── Customsearch.php
│ │ ├── Dataflow.php
│ │ ├── Datastore.php
│ │ ├── Deploymentmanager.php
│ │ ├── Dfareporting.php
│ │ ├── Directory.php
│ │ ├── Dns.php
│ │ ├── DoubleClickBidManager.php
│ │ ├── Doubleclicksearch.php
│ │ ├── Drive.php
│ │ ├── Exception.php
│ │ ├── Fitness.php
│ │ ├── Freebase.php
│ │ ├── Fusiontables.php
│ │ ├── Games.php
│ │ ├── GamesConfiguration.php
│ │ ├── GamesManagement.php
│ │ ├── Genomics.php
│ │ ├── Gmail.php
│ │ ├── GroupsMigration.php
│ │ ├── Groupssettings.php
│ │ ├── IdentityToolkit.php
│ │ ├── Licensing.php
│ │ ├── Manager.php
│ │ ├── MapsEngine.php
│ │ ├── Mirror.php
│ │ ├── Oauth2.php
│ │ ├── Pagespeedonline.php
│ │ ├── Plus.php
│ │ ├── PlusDomains.php
│ │ ├── Prediction.php
│ │ ├── Pubsub.php
│ │ ├── QPXExpress.php
│ │ ├── Replicapool.php
│ │ ├── Replicapoolupdater.php
│ │ ├── Reports.php
│ │ ├── Reseller.php
│ │ ├── Resource.php
│ │ ├── Resourceviews.php
│ │ ├── SQLAdmin.php
│ │ ├── ShoppingContent.php
│ │ ├── SiteVerification.php
│ │ ├── Spectrum.php
│ │ ├── Storage.php
│ │ ├── TagManager.php
│ │ ├── Taskqueue.php
│ │ ├── Tasks.php
│ │ ├── Translate.php
│ │ ├── Urlshortener.php
│ │ ├── Webfonts.php
│ │ ├── Webmasters.php
│ │ ├── YouTube.php
│ │ └── YouTubeAnalytics.php
│ │ ├── Signer
│ │ ├── Abstract.php
│ │ └── P12.php
│ │ ├── Task
│ │ ├── Exception.php
│ │ ├── Retryable.php
│ │ └── Runner.php
│ │ ├── Utils.php
│ │ ├── Utils
│ │ └── URITemplate.php
│ │ └── Verifier
│ │ ├── Abstract.php
│ │ └── Pem.php
├── style
│ └── ruleset.xml
└── tests
│ ├── BaseTest.php
│ ├── OAuthHelper.php
│ ├── README
│ ├── adsense
│ └── AdSenseTest.php
│ ├── bootstrap.php
│ ├── general
│ ├── ApiBatchRequestTest.php
│ ├── ApiCacheParserTest.php
│ ├── ApiClientTest.php
│ ├── ApiMediaFileUploadTest.php
│ ├── ApiModelTest.php
│ ├── ApiOAuth2Test.php
│ ├── AuthTest.php
│ ├── CacheTest.php
│ ├── IoTest.php
│ ├── LoggerTest.php
│ ├── RequestTest.php
│ ├── RestTest.php
│ ├── ServiceTest.php
│ ├── TaskTest.php
│ ├── URITemplateTest.php
│ └── testdata
│ │ ├── cacert.json
│ │ ├── cacert.pem
│ │ ├── cert.p12
│ │ ├── privkey.pem
│ │ ├── test.ini
│ │ └── test_public_key.pem
│ ├── pagespeed
│ └── PageSpeedTest.php
│ ├── plus
│ └── PlusTest.php
│ ├── tasks
│ └── TasksTest.php
│ ├── urlshortener
│ └── UrlShortenerTests.php
│ └── youtube
│ └── YouTubeTest.php
├── index.php
└── index_files
└── formoid1
├── .htaccess
├── JSON.php
├── form.formoid
├── form.php
├── formoid-solid-red.css
├── formoid-solid-red.js
├── formoid.eot
├── formoid.svg
├── formoid.ttf
├── formoid.woff
├── handler.php
├── helpers.php
├── icons.eot
├── icons.svg
├── icons.ttf
├── icons.woff
├── jquery.min.js
└── recaptchalib.php
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **edit: this has been patched. took ~5 years**
2 |
3 | **how to install and use**
4 |
5 | 1. use google developers console to generate api credentials *after enabling drive api* on a new project
6 | 2. edit index.php and insert your clientid, clientsecret and redirecturi starting at line 26
7 | 3. your redirecturi value must be the url that points to index.php
8 | 4. navigate to index.php after hosting it on a local or remote webserver
9 |
10 | 
11 |
12 | **full name information leak in google drive**
13 |
14 | in 2015 i discovered and reported this leak found in both mapsengine and drive. mapsengine was patched, but it was evidently a feature in drive. many email accounts across several providers whose names aren't visible on g+ or in account recovery procedures become retrievable. this issue was disclosed to google back in 2015.
15 |
16 | **fyi**
17 |
18 | this reveals *way* more full names than account recovery procedures, the "to" field in new emails, etc. and as such [seclists.org commentators](https://seclists.org/fulldisclosure/2015/Jan/95) were and still are [dead wrong](https://youtu.be/gwpFaU7FwtQ?t=117) ¯\\_(ツ)_/¯
19 |
20 | 
21 |
22 | lulz full disclosure
23 |
--------------------------------------------------------------------------------
/google-api-php-client/.gitignore:
--------------------------------------------------------------------------------
1 | phpunit.xml
2 | composer.lock
3 | vendor
4 | examples/testfile-small.txt
5 | examples/testfile.txt
6 |
--------------------------------------------------------------------------------
/google-api-php-client/.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 | php:
14 | # Can't test against 5.2; openssl is not available:
15 | # http://docs.travis-ci.com/user/languages/php/#PHP-installation
16 | - 5.3
17 | - 5.4
18 | - 5.5
19 | - 5.6
20 | - hhvm
21 |
22 | before_script:
23 | - composer install
24 | - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension=memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
25 | - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension=memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
26 | - phpenv version-name | grep ^5.[34] && echo "extension=apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true
27 | - phpenv version-name | grep ^5.[34] && echo "apc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true
28 |
29 | script:
30 | - vendor/bin/phpunit
31 |
--------------------------------------------------------------------------------
/google-api-php-client/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 |
--------------------------------------------------------------------------------
/google-api-php-client/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/google/google-api-php-client)
2 |
3 | # Google APIs Client Library for PHP #
4 |
5 | ## Description ##
6 | The Google API Client Library enables you to work with Google APIs such as Google+, Drive, or YouTube on your server.
7 |
8 | ## Beta ##
9 | This library is in Beta. We're comfortable enough with the stability and features of the library that we want you to build real production applications on it. We will make an effort to support the public and protected surface of the library and maintain backwards compatibility in the future. While we are still in Beta, we reserve the right to make incompatible changes. If we do remove some functionality (typically because better functionality exists or if the feature proved infeasible), our intention is to deprecate and provide ample time for developers to update their code.
10 |
11 | ## Requirements ##
12 | * [PHP 5.2.1 or higher](http://www.php.net/)
13 | * [PHP JSON extension](http://php.net/manual/en/book.json.php)
14 |
15 | *Note*: some features (service accounts and id token verification) require PHP 5.3.0 and above due to cryptographic algorithm requirements.
16 |
17 | ## Developer Documentation ##
18 | http://developers.google.com/api-client-library/php
19 |
20 | ## Installation ##
21 |
22 | For the latest installation and setup instructions, see [the documentation](https://developers.google.com/api-client-library/php/start/installation).
23 |
24 | ## Basic Example ##
25 | See the examples/ directory for examples of the key client features.
26 | ```PHP
27 | setApplicationName("Client_Library_Examples");
33 | $client->setDeveloperKey("YOUR_APP_KEY");
34 |
35 | $service = new Google_Service_Books($client);
36 | $optParams = array('filter' => 'free-ebooks');
37 | $results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
38 |
39 | foreach ($results as $item) {
40 | echo $item['volumeInfo']['title'], "
\n";
41 | }
42 |
43 | ```
44 |
45 | ## Frequently Asked Questions ##
46 |
47 | ### What do I do if something isn't working? ###
48 |
49 | For support with the library the best place to ask is via the google-api-php-client tag on StackOverflow: http://stackoverflow.com/questions/tagged/google-api-php-client
50 |
51 | If there is a specific bug with the library, please file a issue in the Github issues tracker, including a (minimal) example of the failing code and any specific errors retrieved. Feature requests can also be filed, as long as they are core library requests, and not-API specific: for those, refer to the documentation for the individual APIs for the best place to file requests. Please try to provide a clear statement of the problem that the feature would address.
52 |
53 | ### How do I contribute? ###
54 |
55 | We accept contributions via Github Pull Requests, but all contributors need to be covered by the standard Google Contributor License Agreement. You can find links, and more instructions, in the documentation: https://developers.google.com/api-client-library/php/contribute
56 |
57 | ### Why do you still support 5.2? ###
58 |
59 | When we started working on the 1.0.0 branch we knew there were several fundamental issues to fix with the 0.6 releases of the library. At that time we looked at the usage of the library, and other related projects, and determined that there was still a large and active base of PHP 5.2 installs. You can see this in statistics such as the PHP versions chart in the WordPress stats: http://wordpress.org/about/stats/. We will keep looking at the types of usage we see, and try to take advantage of newer PHP features where possible.
60 |
61 | ### Why does Google_..._Service have weird names? ###
62 |
63 | The _Service classes are generally automatically generated from the API discovery documents: https://developers.google.com/discovery/. Sometimes new features are added to APIs with unusual names, which can cause some unexpected or non-standard style naming in the PHP classes.
64 |
65 | ### How do I deal with non-JSON response types? ###
66 |
67 | Some services return XML or similar by default, rather than JSON, which is what the library supports. You can request a JSON response by adding an 'alt' argument to optional params that is normally the last argument to a method call:
68 |
69 | ```
70 | $opt_params = array(
71 | 'alt' => "json"
72 | );
73 | ```
74 |
75 | ## Code Quality ##
76 |
77 | Copy the ruleset.xml in style/ into a new directory named GAPI/ in your
78 | /usr/share/php/PHP/CodeSniffer/Standards (or appropriate equivalent directory),
79 | and run code sniffs with:
80 |
81 | phpcs --standard=GAPI src/
82 |
--------------------------------------------------------------------------------
/google-api-php-client/autoload.php:
--------------------------------------------------------------------------------
1 | 3) {
24 | // Maximum class file path depth in this project is 3.
25 | $classPath = array_slice($classPath, 0, 3);
26 | }
27 | $filePath = dirname(__FILE__) . '/src/' . implode('/', $classPath) . '.php';
28 | if (file_exists($filePath)) {
29 | require_once($filePath);
30 | }
31 | }
32 |
33 | spl_autoload_register('google_api_php_client_autoload');
34 |
--------------------------------------------------------------------------------
/google-api-php-client/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 | },
14 | "autoload": {
15 | "classmap": [
16 | "src/"
17 | ]
18 | },
19 | "extra": {
20 | "branch-alias": {
21 | "dev-master": "1.1.x-dev"
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/google-api-php-client/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 "
"; 43 | var_dump($results); 44 | echo ""; 45 | 46 | echo pageFooter(__FILE__); 47 | -------------------------------------------------------------------------------- /google-api-php-client/examples/batch.php: -------------------------------------------------------------------------------- 1 | setApplicationName("Client_Library_Examples"); 35 | $apiKey = "
"; 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 |
25 | * For more information about this service, see the API 26 | * Documentation 27 | *
28 | * 29 | * @author Google, Inc. 30 | */ 31 | class Google_Service_Admin extends Google_Service 32 | { 33 | /** Manage email messages of users on your domain. */ 34 | const EMAIL_MIGRATION = 35 | "https://www.googleapis.com/auth/email.migration"; 36 | 37 | public $mail; 38 | 39 | 40 | /** 41 | * Constructs the internal representation of the Admin service. 42 | * 43 | * @param Google_Client $client 44 | */ 45 | public function __construct(Google_Client $client) 46 | { 47 | parent::__construct($client); 48 | $this->servicePath = 'email/v2/users/'; 49 | $this->version = 'email_migration_v2'; 50 | $this->serviceName = 'admin'; 51 | 52 | $this->mail = new Google_Service_Admin_Mail_Resource( 53 | $this, 54 | $this->serviceName, 55 | 'mail', 56 | array( 57 | 'methods' => array( 58 | 'insert' => array( 59 | 'path' => '{userKey}/mail', 60 | 'httpMethod' => 'POST', 61 | 'parameters' => array( 62 | 'userKey' => array( 63 | 'location' => 'path', 64 | 'type' => 'string', 65 | 'required' => true, 66 | ), 67 | ), 68 | ), 69 | ) 70 | ) 71 | ); 72 | } 73 | } 74 | 75 | 76 | /** 77 | * The "mail" collection of methods. 78 | * Typical usage is: 79 | *
80 | * $adminService = new Google_Service_Admin(...);
81 | * $mail = $adminService->mail;
82 | *
83 | */
84 | class Google_Service_Admin_Mail_Resource extends Google_Service_Resource
85 | {
86 |
87 | /**
88 | * Insert Mail into Google's Gmail backends (mail.insert)
89 | *
90 | * @param string $userKey The email or immutable id of the user
91 | * @param Google_MailItem $postBody
92 | * @param array $optParams Optional parameters.
93 | */
94 | public function insert($userKey, Google_Service_Admin_MailItem $postBody, $optParams = array())
95 | {
96 | $params = array('userKey' => $userKey, 'postBody' => $postBody);
97 | $params = array_merge($params, $optParams);
98 | return $this->call('insert', array($params));
99 | }
100 | }
101 |
102 |
103 |
104 |
105 | class Google_Service_Admin_MailItem extends Google_Collection
106 | {
107 | protected $collection_key = 'labels';
108 | protected $internal_gapi_mappings = array(
109 | );
110 | public $isDeleted;
111 | public $isDraft;
112 | public $isInbox;
113 | public $isSent;
114 | public $isStarred;
115 | public $isTrash;
116 | public $isUnread;
117 | public $kind;
118 | public $labels;
119 |
120 |
121 | public function setIsDeleted($isDeleted)
122 | {
123 | $this->isDeleted = $isDeleted;
124 | }
125 | public function getIsDeleted()
126 | {
127 | return $this->isDeleted;
128 | }
129 | public function setIsDraft($isDraft)
130 | {
131 | $this->isDraft = $isDraft;
132 | }
133 | public function getIsDraft()
134 | {
135 | return $this->isDraft;
136 | }
137 | public function setIsInbox($isInbox)
138 | {
139 | $this->isInbox = $isInbox;
140 | }
141 | public function getIsInbox()
142 | {
143 | return $this->isInbox;
144 | }
145 | public function setIsSent($isSent)
146 | {
147 | $this->isSent = $isSent;
148 | }
149 | public function getIsSent()
150 | {
151 | return $this->isSent;
152 | }
153 | public function setIsStarred($isStarred)
154 | {
155 | $this->isStarred = $isStarred;
156 | }
157 | public function getIsStarred()
158 | {
159 | return $this->isStarred;
160 | }
161 | public function setIsTrash($isTrash)
162 | {
163 | $this->isTrash = $isTrash;
164 | }
165 | public function getIsTrash()
166 | {
167 | return $this->isTrash;
168 | }
169 | public function setIsUnread($isUnread)
170 | {
171 | $this->isUnread = $isUnread;
172 | }
173 | public function getIsUnread()
174 | {
175 | return $this->isUnread;
176 | }
177 | public function setKind($kind)
178 | {
179 | $this->kind = $kind;
180 | }
181 | public function getKind()
182 | {
183 | return $this->kind;
184 | }
185 | public function setLabels($labels)
186 | {
187 | $this->labels = $labels;
188 | }
189 | public function getLabels()
190 | {
191 | return $this->labels;
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/google-api-php-client/src/Google/Service/Exception.php:
--------------------------------------------------------------------------------
1 | = 0) {
51 | parent::__construct($message, $code, $previous);
52 | } else {
53 | parent::__construct($message, $code);
54 | }
55 |
56 | $this->errors = $errors;
57 |
58 | if (is_array($retryMap)) {
59 | $this->retryMap = $retryMap;
60 | }
61 | }
62 |
63 | /**
64 | * An example of the possible errors returned.
65 | *
66 | * {
67 | * "domain": "global",
68 | * "reason": "authError",
69 | * "message": "Invalid Credentials",
70 | * "locationType": "header",
71 | * "location": "Authorization",
72 | * }
73 | *
74 | * @return [{string, string}] List of errors return in an HTTP response or [].
75 | */
76 | public function getErrors()
77 | {
78 | return $this->errors;
79 | }
80 |
81 | /**
82 | * Gets the number of times the associated task can be retried.
83 | *
84 | * NOTE: -1 is returned if the task can be retried indefinitely
85 | *
86 | * @return integer
87 | */
88 | public function allowedRetries()
89 | {
90 | if (isset($this->retryMap[$this->code])) {
91 | return $this->retryMap[$this->code];
92 | }
93 |
94 | $errors = $this->getErrors();
95 |
96 | if (!empty($errors) && isset($errors[0]['reason']) &&
97 | isset($this->retryMap[$errors[0]['reason']])) {
98 | return $this->retryMap[$errors[0]['reason']];
99 | }
100 |
101 | return 0;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/google-api-php-client/src/Google/Service/GroupsMigration.php:
--------------------------------------------------------------------------------
1 |
22 | * Groups Migration Api.
23 | *
24 | * 25 | * For more information about this service, see the API 26 | * Documentation 27 | *
28 | * 29 | * @author Google, Inc. 30 | */ 31 | class Google_Service_GroupsMigration extends Google_Service 32 | { 33 | 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->servicePath = 'groups/v1/groups/'; 47 | $this->version = 'v1'; 48 | $this->serviceName = 'groupsmigration'; 49 | 50 | $this->archive = new Google_Service_GroupsMigration_Archive_Resource( 51 | $this, 52 | $this->serviceName, 53 | 'archive', 54 | array( 55 | 'methods' => array( 56 | 'insert' => array( 57 | 'path' => '{groupId}/archive', 58 | 'httpMethod' => 'POST', 59 | 'parameters' => array( 60 | 'groupId' => array( 61 | 'location' => 'path', 62 | 'type' => 'string', 63 | 'required' => true, 64 | ), 65 | ), 66 | ), 67 | ) 68 | ) 69 | ); 70 | } 71 | } 72 | 73 | 74 | /** 75 | * The "archive" collection of methods. 76 | * Typical usage is: 77 | *
78 | * $groupsmigrationService = new Google_Service_GroupsMigration(...);
79 | * $archive = $groupsmigrationService->archive;
80 | *
81 | */
82 | class Google_Service_GroupsMigration_Archive_Resource extends Google_Service_Resource
83 | {
84 |
85 | /**
86 | * Inserts a new mail into the archive of the Google group. (archive.insert)
87 | *
88 | * @param string $groupId The group ID
89 | * @param array $optParams Optional parameters.
90 | * @return Google_Service_GroupsMigration_Groups
91 | */
92 | public function insert($groupId, $optParams = array())
93 | {
94 | $params = array('groupId' => $groupId);
95 | $params = array_merge($params, $optParams);
96 | return $this->call('insert', array($params), "Google_Service_GroupsMigration_Groups");
97 | }
98 | }
99 |
100 |
101 |
102 |
103 | class Google_Service_GroupsMigration_Groups extends Google_Model
104 | {
105 | protected $internal_gapi_mappings = array(
106 | );
107 | public $kind;
108 | public $responseCode;
109 |
110 |
111 | public function setKind($kind)
112 | {
113 | $this->kind = $kind;
114 | }
115 | public function getKind()
116 | {
117 | return $this->kind;
118 | }
119 | public function setResponseCode($responseCode)
120 | {
121 | $this->responseCode = $responseCode;
122 | }
123 | public function getResponseCode()
124 | {
125 | return $this->responseCode;
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/google-api-php-client/src/Google/Service/Webfonts.php:
--------------------------------------------------------------------------------
1 |
22 | * The Google Fonts Developer API.
23 | *
24 | * 25 | * For more information about this service, see the API 26 | * Documentation 27 | *
28 | * 29 | * @author Google, Inc. 30 | */ 31 | class Google_Service_Webfonts extends Google_Service 32 | { 33 | 34 | 35 | public $webfonts; 36 | 37 | 38 | /** 39 | * Constructs the internal representation of the Webfonts service. 40 | * 41 | * @param Google_Client $client 42 | */ 43 | public function __construct(Google_Client $client) 44 | { 45 | parent::__construct($client); 46 | $this->servicePath = 'webfonts/v1/'; 47 | $this->version = 'v1'; 48 | $this->serviceName = 'webfonts'; 49 | 50 | $this->webfonts = new Google_Service_Webfonts_Webfonts_Resource( 51 | $this, 52 | $this->serviceName, 53 | 'webfonts', 54 | array( 55 | 'methods' => array( 56 | 'list' => array( 57 | 'path' => 'webfonts', 58 | 'httpMethod' => 'GET', 59 | 'parameters' => array( 60 | 'sort' => array( 61 | 'location' => 'query', 62 | 'type' => 'string', 63 | ), 64 | ), 65 | ), 66 | ) 67 | ) 68 | ); 69 | } 70 | } 71 | 72 | 73 | /** 74 | * The "webfonts" collection of methods. 75 | * Typical usage is: 76 | *
77 | * $webfontsService = new Google_Service_Webfonts(...);
78 | * $webfonts = $webfontsService->webfonts;
79 | *
80 | */
81 | class Google_Service_Webfonts_Webfonts_Resource extends Google_Service_Resource
82 | {
83 |
84 | /**
85 | * Retrieves the list of fonts currently served by the Google Fonts Developer
86 | * API (webfonts.listWebfonts)
87 | *
88 | * @param array $optParams Optional parameters.
89 | *
90 | * @opt_param string sort Enables sorting of the list
91 | * @return Google_Service_Webfonts_WebfontList
92 | */
93 | public function listWebfonts($optParams = array())
94 | {
95 | $params = array();
96 | $params = array_merge($params, $optParams);
97 | return $this->call('list', array($params), "Google_Service_Webfonts_WebfontList");
98 | }
99 | }
100 |
101 |
102 |
103 |
104 | class Google_Service_Webfonts_Webfont extends Google_Collection
105 | {
106 | protected $collection_key = 'variants';
107 | protected $internal_gapi_mappings = array(
108 | );
109 | public $category;
110 | public $family;
111 | public $files;
112 | public $kind;
113 | public $lastModified;
114 | public $subsets;
115 | public $variants;
116 | public $version;
117 |
118 |
119 | public function setCategory($category)
120 | {
121 | $this->category = $category;
122 | }
123 | public function getCategory()
124 | {
125 | return $this->category;
126 | }
127 | public function setFamily($family)
128 | {
129 | $this->family = $family;
130 | }
131 | public function getFamily()
132 | {
133 | return $this->family;
134 | }
135 | public function setFiles($files)
136 | {
137 | $this->files = $files;
138 | }
139 | public function getFiles()
140 | {
141 | return $this->files;
142 | }
143 | public function setKind($kind)
144 | {
145 | $this->kind = $kind;
146 | }
147 | public function getKind()
148 | {
149 | return $this->kind;
150 | }
151 | public function setLastModified($lastModified)
152 | {
153 | $this->lastModified = $lastModified;
154 | }
155 | public function getLastModified()
156 | {
157 | return $this->lastModified;
158 | }
159 | public function setSubsets($subsets)
160 | {
161 | $this->subsets = $subsets;
162 | }
163 | public function getSubsets()
164 | {
165 | return $this->subsets;
166 | }
167 | public function setVariants($variants)
168 | {
169 | $this->variants = $variants;
170 | }
171 | public function getVariants()
172 | {
173 | return $this->variants;
174 | }
175 | public function setVersion($version)
176 | {
177 | $this->version = $version;
178 | }
179 | public function getVersion()
180 | {
181 | return $this->version;
182 | }
183 | }
184 |
185 | class Google_Service_Webfonts_WebfontFiles extends Google_Model
186 | {
187 | }
188 |
189 | class Google_Service_Webfonts_WebfontList extends Google_Collection
190 | {
191 | protected $collection_key = 'items';
192 | protected $internal_gapi_mappings = array(
193 | );
194 | protected $itemsType = 'Google_Service_Webfonts_Webfont';
195 | protected $itemsDataType = 'array';
196 | public $kind;
197 |
198 |
199 | public function setItems($items)
200 | {
201 | $this->items = $items;
202 | }
203 | public function getItems()
204 | {
205 | return $this->items;
206 | }
207 | public function setKind($kind)
208 | {
209 | $this->kind = $kind;
210 | }
211 | public function getKind()
212 | {
213 | return $this->kind;
214 | }
215 | }
216 |
--------------------------------------------------------------------------------
/google-api-php-client/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 |
--------------------------------------------------------------------------------
/google-api-php-client/src/Google/Signer/P12.php:
--------------------------------------------------------------------------------
1 |
26 | */
27 | class Google_Signer_P12 extends Google_Signer_Abstract
28 | {
29 | // OpenSSL private key resource
30 | private $privateKey;
31 |
32 | // Creates a new signer from a .p12 file.
33 | public function __construct($p12, $password)
34 | {
35 | if (!function_exists('openssl_x509_read')) {
36 | throw new Google_Exception(
37 | 'The Google PHP API library needs the openssl PHP extension'
38 | );
39 | }
40 |
41 | // If the private key is provided directly, then this isn't in the p12
42 | // format. Different versions of openssl support different p12 formats
43 | // and the key from google wasn't being accepted by the version available
44 | // at the time.
45 | if (!$password && strpos($p12, "-----BEGIN RSA PRIVATE KEY-----") !== false) {
46 | $this->privateKey = openssl_pkey_get_private($p12);
47 | } else {
48 | // This throws on error
49 | $certs = array();
50 | if (!openssl_pkcs12_read($p12, $certs, $password)) {
51 | throw new Google_Auth_Exception(
52 | "Unable to parse the p12 file. " .
53 | "Is this a .p12 file? Is the password correct? OpenSSL error: " .
54 | openssl_error_string()
55 | );
56 | }
57 | // TODO(beaton): is this part of the contract for the openssl_pkcs12_read
58 | // method? What happens if there are multiple private keys? Do we care?
59 | if (!array_key_exists("pkey", $certs) || !$certs["pkey"]) {
60 | throw new Google_Auth_Exception("No private key found in p12 file.");
61 | }
62 | $this->privateKey = openssl_pkey_get_private($certs['pkey']);
63 | }
64 |
65 | if (!$this->privateKey) {
66 | throw new Google_Auth_Exception("Unable to load private key");
67 | }
68 | }
69 |
70 | public function __destruct()
71 | {
72 | if ($this->privateKey) {
73 | openssl_pkey_free($this->privateKey);
74 | }
75 | }
76 |
77 | public function sign($data)
78 | {
79 | if (version_compare(PHP_VERSION, '5.3.0') < 0) {
80 | throw new Google_Auth_Exception(
81 | "PHP 5.3.0 or higher is required to use service accounts."
82 | );
83 | }
84 | $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256";
85 | if (!openssl_sign($data, $signature, $this->privateKey, $hash)) {
86 | throw new Google_Auth_Exception("Unable to sign data");
87 | }
88 | return $signature;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/google-api-php-client/src/Google/Task/Exception.php:
--------------------------------------------------------------------------------
1 |
23 | */
24 | class Google_Utils
25 | {
26 | public static function urlSafeB64Encode($data)
27 | {
28 | $b64 = base64_encode($data);
29 | $b64 = str_replace(
30 | array('+', '/', '\r', '\n', '='),
31 | array('-', '_'),
32 | $b64
33 | );
34 | return $b64;
35 | }
36 |
37 | public static function urlSafeB64Decode($b64)
38 | {
39 | $b64 = str_replace(
40 | array('-', '_'),
41 | array('+', '/'),
42 | $b64
43 | );
44 | return base64_decode($b64);
45 | }
46 |
47 | /**
48 | * Misc function used to count the number of bytes in a post body, in the
49 | * world of multi-byte chars and the unpredictability of
50 | * strlen/mb_strlen/sizeof, this is the only way to do that in a sane
51 | * manner at the moment.
52 | *
53 | * This algorithm was originally developed for the
54 | * Solar Framework by Paul M. Jones
55 | *
56 | * @link http://solarphp.com/
57 | * @link http://svn.solarphp.com/core/trunk/Solar/Json.php
58 | * @link http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Json/Decoder.php
59 | * @param string $str
60 | * @return int The number of bytes in a string.
61 | */
62 | public static function getStrLen($str)
63 | {
64 | $strlenVar = strlen($str);
65 | $d = $ret = 0;
66 | for ($count = 0; $count < $strlenVar; ++ $count) {
67 | $ordinalValue = ord($str{$ret});
68 | switch (true) {
69 | case (($ordinalValue >= 0x20) && ($ordinalValue <= 0x7F)):
70 | // characters U-00000000 - U-0000007F (same as ASCII)
71 | $ret ++;
72 | break;
73 | case (($ordinalValue & 0xE0) == 0xC0):
74 | // characters U-00000080 - U-000007FF, mask 110XXXXX
75 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
76 | $ret += 2;
77 | break;
78 | case (($ordinalValue & 0xF0) == 0xE0):
79 | // characters U-00000800 - U-0000FFFF, mask 1110XXXX
80 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
81 | $ret += 3;
82 | break;
83 | case (($ordinalValue & 0xF8) == 0xF0):
84 | // characters U-00010000 - U-001FFFFF, mask 11110XXX
85 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
86 | $ret += 4;
87 | break;
88 | case (($ordinalValue & 0xFC) == 0xF8):
89 | // characters U-00200000 - U-03FFFFFF, mask 111110XX
90 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
91 | $ret += 5;
92 | break;
93 | case (($ordinalValue & 0xFE) == 0xFC):
94 | // characters U-04000000 - U-7FFFFFFF, mask 1111110X
95 | // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
96 | $ret += 6;
97 | break;
98 | default:
99 | $ret ++;
100 | }
101 | }
102 | return $ret;
103 | }
104 |
105 | /**
106 | * Normalize all keys in an array to lower-case.
107 | * @param array $arr
108 | * @return array Normalized array.
109 | */
110 | public static function normalize($arr)
111 | {
112 | if (!is_array($arr)) {
113 | return array();
114 | }
115 |
116 | $normalized = array();
117 | foreach ($arr as $key => $val) {
118 | $normalized[strtolower($key)] = $val;
119 | }
120 | return $normalized;
121 | }
122 |
123 | /**
124 | * Convert a string to camelCase
125 | * @param string $value
126 | * @return string
127 | */
128 | public static function camelCase($value)
129 | {
130 | $value = ucwords(str_replace(array('-', '_'), ' ', $value));
131 | $value = str_replace(' ', '', $value);
132 | $value[0] = strtolower($value[0]);
133 | return $value;
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/google-api-php-client/src/Google/Verifier/Abstract.php:
--------------------------------------------------------------------------------
1 |
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 |
--------------------------------------------------------------------------------
/google-api-php-client/src/Google/Verifier/Pem.php:
--------------------------------------------------------------------------------
1 |
24 | */
25 | class Google_Verifier_Pem extends Google_Verifier_Abstract
26 | {
27 | private $publicKey;
28 |
29 | /**
30 | * Constructs a verifier from the supplied PEM-encoded certificate.
31 | *
32 | * $pem: a PEM encoded certificate (not a file).
33 | * @param $pem
34 | * @throws Google_Auth_Exception
35 | * @throws Google_Exception
36 | */
37 | public function __construct($pem)
38 | {
39 | if (!function_exists('openssl_x509_read')) {
40 | throw new Google_Exception('Google API PHP client needs the openssl PHP extension');
41 | }
42 | $this->publicKey = openssl_x509_read($pem);
43 | if (!$this->publicKey) {
44 | throw new Google_Auth_Exception("Unable to parse PEM: $pem");
45 | }
46 | }
47 |
48 | public function __destruct()
49 | {
50 | if ($this->publicKey) {
51 | openssl_x509_free($this->publicKey);
52 | }
53 | }
54 |
55 | /**
56 | * Verifies the signature on data.
57 | *
58 | * Returns true if the signature is valid, false otherwise.
59 | * @param $data
60 | * @param $signature
61 | * @throws Google_Auth_Exception
62 | * @return bool
63 | */
64 | public function verify($data, $signature)
65 | {
66 | $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256";
67 | $status = openssl_verify($data, $signature, $this->publicKey, $hash);
68 | if ($status === -1) {
69 | throw new Google_Auth_Exception('Signature verification error: ' . openssl_error_string());
70 | }
71 | return $status === 1;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/google-api-php-client/tests/BaseTest.php:
--------------------------------------------------------------------------------
1 | token = '';
31 |
32 | $this->memcacheHost = getenv('MEMCACHE_HOST') ? getenv('MEMCACHE_HOST') : null;
33 | $this->memcachePort = getenv('MEMCACHE_PORT') ? getenv('MEMCACHE_PORT') : null;
34 | }
35 |
36 | public function getClient()
37 | {
38 | $client = new Google_Client();
39 | $client->setDeveloperKey(self::KEY);
40 | if (strlen($this->token)) {
41 | $client->setAccessToken($this->token);
42 | }
43 | if (strlen($this->memcacheHost)) {
44 | $client->setClassConfig('Google_Cache_Memcache', 'host', $this->memcacheHost);
45 | $client->setClassConfig('Google_Cache_Memcache', 'port', $this->memcachePort);
46 | }
47 | return $client;
48 | }
49 |
50 | public function checkToken()
51 | {
52 | if (!strlen($this->token)) {
53 | $this->markTestSkipped('Test requires access token');
54 | return false;
55 | }
56 | return true;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/google-api-php-client/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 | $client->setClientId("");
34 | $client->setClientSecret("");
35 |
36 | $authUrl = $client->createAuthUrl();
37 |
38 | `open '$authUrl'`;
39 | echo "\nPlease enter the auth code:\n";
40 | $authCode = trim(fgets(STDIN));
41 |
42 | $accessToken = $client->authenticate($authCode);
43 |
44 | echo "\n", 'Add the following to BaseTest.php as the $token value:', "\n\n";
45 | echo $accessToken, "\n\n";
46 |
--------------------------------------------------------------------------------
/google-api-php-client/tests/README:
--------------------------------------------------------------------------------
1 | These tests depend on PHPUnit, see
2 | http://www.phpunit.de/manual/current/en/installation.html for more instructions
3 |
--------------------------------------------------------------------------------
/google-api-php-client/tests/bootstrap.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 |
--------------------------------------------------------------------------------
/google-api-php-client/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 |
--------------------------------------------------------------------------------
/google-api-php-client/tests/general/ApiModelTest.php:
--------------------------------------------------------------------------------
1 | setDate($dateString);
68 | $event->setStart($date);
69 | $event->setEnd($date);
70 | $event->setSummary($summary);
71 | $simpleEvent = $event->toSimpleObject();
72 | $this->assertEquals($dateString, $simpleEvent->start->date);
73 | $this->assertEquals($dateString, $simpleEvent->end->date);
74 | $this->assertEquals($summary, $simpleEvent->summary);
75 |
76 | $event2 = new Google_Service_Calendar_Event();
77 | $this->assertNull($event2->getStart());
78 | }
79 |
80 | public function testVariantTypes()
81 | {
82 | $feature = new Google_Service_MapsEngine_Feature();
83 | $geometry = new Google_Service_MapsEngine_GeoJsonPoint();
84 | $geometry->setCoordinates(array(1, 0));
85 | $feature->setGeometry($geometry);
86 | $data = json_decode(json_encode($feature->toSimpleObject()), true);
87 | $this->assertEquals('Point', $data['geometry']['type']);
88 | $this->assertEquals(1, $data['geometry']['coordinates'][0]);
89 | }
90 |
91 | public function testOddMappingNames()
92 | {
93 | $creative = new Google_Service_AdExchangeBuyer_Creative();
94 | $creative->setAccountId('12345');
95 | $creative->setBuyerCreativeId('12345');
96 | $creative->setAdvertiserName('Hi');
97 | $creative->setHTMLSnippet("Foo!
"); 98 | $creative->setClickThroughUrl(array('http://somedomain.com')); 99 | $creative->setWidth(100); 100 | $creative->setHeight(100); 101 | $data = json_decode(json_encode($creative->toSimpleObject()), true); 102 | $this->assertEquals($data['HTMLSnippet'], "Foo!
"); 103 | $this->assertEquals($data['width'], 100); 104 | $this->assertEquals($data['height'], 100); 105 | $this->assertEquals($data['accountId'], "12345"); 106 | } 107 | 108 | public function testJsonStructure() 109 | { 110 | $model = new Google_Model(); 111 | $model->publicA = "This is a string"; 112 | $model2 = new Google_Model(); 113 | $model2->publicC = 12345; 114 | $model2->publicD = null; 115 | $model->publicB = $model2; 116 | $model3 = new Google_Model(); 117 | $model3->publicE = 54321; 118 | $model3->publicF = null; 119 | $model->publicG = array($model3, "hello", false); 120 | $model->publicH = false; 121 | $model->publicI = 0; 122 | $string = json_encode($model->toSimpleObject()); 123 | $data = json_decode($string, true); 124 | $this->assertEquals(12345, $data['publicB']['publicC']); 125 | $this->assertEquals("This is a string", $data['publicA']); 126 | $this->assertArrayNotHasKey("publicD", $data['publicB']); 127 | $this->assertArrayHasKey("publicE", $data['publicG'][0]); 128 | $this->assertArrayNotHasKey("publicF", $data['publicG'][0]); 129 | $this->assertEquals("hello", $data['publicG'][1]); 130 | $this->assertEquals(false, $data['publicG'][2]); 131 | $this->assertArrayNotHasKey("data", $data); 132 | $this->assertEquals(false, $data['publicH']); 133 | $this->assertEquals(0, $data['publicI']); 134 | } 135 | 136 | public function testIssetPropertyOnModel() 137 | { 138 | $model = new Google_Model(); 139 | $model['foo'] = 'bar'; 140 | $this->assertTrue(isset($model->foo)); 141 | } 142 | 143 | public function testUnsetPropertyOnModel() 144 | { 145 | $model = new Google_Model(); 146 | $model['foo'] = 'bar'; 147 | unset($model->foo); 148 | $this->assertFalse(isset($model->foo)); 149 | } 150 | 151 | public function testCollection() 152 | { 153 | $data = json_decode( 154 | '{ 155 | "kind": "calendar#events", 156 | "id": "1234566", 157 | "etag": "abcdef", 158 | "totalItems": 4, 159 | "items": [ 160 | {"id": 1}, 161 | {"id": 2}, 162 | {"id": 3}, 163 | {"id": 4} 164 | ] 165 | }', 166 | true 167 | ); 168 | $collection = new Google_Service_Calendar_Events($data); 169 | $this->assertEquals(4, count($collection)); 170 | $count = 0; 171 | foreach ($collection as $col) { 172 | $count++; 173 | } 174 | $this->assertEquals(4, $count); 175 | $this->assertEquals(1, $collection[0]->id); 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /google-api-php-client/tests/general/CacheTest.php: -------------------------------------------------------------------------------- 1 | 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 | -------------------------------------------------------------------------------- /google-api-php-client/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 | -------------------------------------------------------------------------------- /google-api-php-client/tests/general/RestTest.php: -------------------------------------------------------------------------------- 1 | rest = new Google_Http_REST(); 28 | } 29 | 30 | public function testDecodeResponse() 31 | { 32 | $url = 'http://localhost'; 33 | $client = $this->getClient(); 34 | $response = new Google_Http_Request($url); 35 | $response->setResponseHttpCode(204); 36 | $decoded = $this->rest->decodeHttpResponse($response, $client); 37 | $this->assertEquals(null, $decoded); 38 | 39 | 40 | foreach (array(200, 201) as $code) { 41 | $headers = array('foo', 'bar'); 42 | $response = new Google_Http_Request($url, 'GET', $headers); 43 | $response->setResponseBody('{"a": 1}'); 44 | 45 | $response->setResponseHttpCode($code); 46 | $decoded = $this->rest->decodeHttpResponse($response, $client); 47 | $this->assertEquals(array("a" => 1), $decoded); 48 | } 49 | 50 | $response = new Google_Http_Request($url); 51 | $response->setResponseHttpCode(500); 52 | 53 | $error = ""; 54 | try { 55 | $this->rest->decodeHttpResponse($response, $client); 56 | } catch (Exception $e) { 57 | $error = $e->getMessage(); 58 | 59 | } 60 | $this->assertEquals(trim($error), "Error calling GET http://localhost: (500)"); 61 | } 62 | 63 | 64 | public function testDecodeEmptyResponse() 65 | { 66 | $url = 'http://localhost'; 67 | 68 | $response = new Google_Http_Request($url, 'GET', array()); 69 | $response->setResponseBody('{}'); 70 | 71 | $response->setResponseHttpCode(200); 72 | $decoded = $this->rest->decodeHttpResponse($response); 73 | $this->assertEquals(array(), $decoded); 74 | } 75 | 76 | public function testCreateRequestUri() 77 | { 78 | $basePath = "http://localhost"; 79 | $restPath = "/plus/{u}"; 80 | 81 | // Test Path 82 | $params = array(); 83 | $params['u']['type'] = 'string'; 84 | $params['u']['location'] = 'path'; 85 | $params['u']['value'] = 'me'; 86 | $value = $this->rest->createRequestUri($basePath, $restPath, $params); 87 | $this->assertEquals("http://localhost/plus/me", $value); 88 | 89 | // Test Query 90 | $params = array(); 91 | $params['u']['type'] = 'string'; 92 | $params['u']['location'] = 'query'; 93 | $params['u']['value'] = 'me'; 94 | $value = $this->rest->createRequestUri($basePath, '/plus', $params); 95 | $this->assertEquals("http://localhost/plus?u=me", $value); 96 | 97 | // Test Booleans 98 | $params = array(); 99 | $params['u']['type'] = 'boolean'; 100 | $params['u']['location'] = 'path'; 101 | $params['u']['value'] = '1'; 102 | $value = $this->rest->createRequestUri($basePath, $restPath, $params); 103 | $this->assertEquals("http://localhost/plus/true", $value); 104 | 105 | $params['u']['location'] = 'query'; 106 | $value = $this->rest->createRequestUri($basePath, '/plus', $params); 107 | $this->assertEquals("http://localhost/plus?u=true", $value); 108 | 109 | // Test encoding 110 | $params = array(); 111 | $params['u']['type'] = 'string'; 112 | $params['u']['location'] = 'query'; 113 | $params['u']['value'] = '@me/'; 114 | $value = $this->rest->createRequestUri($basePath, '/plus', $params); 115 | $this->assertEquals("http://localhost/plus?u=%40me%2F", $value); 116 | } 117 | 118 | /** 119 | * @expectedException Google_Service_Exception 120 | */ 121 | public function testBadErrorFormatting() 122 | { 123 | $request = new Google_Http_Request("/a/b"); 124 | $request->setResponseHttpCode(500); 125 | $request->setResponseBody( 126 | '{ 127 | "error": { 128 | "code": 500, 129 | "message": null 130 | } 131 | }' 132 | ); 133 | Google_Http_Rest::decodeHttpResponse($request); 134 | } 135 | 136 | /** 137 | * @expectedException Google_Service_Exception 138 | */ 139 | public function tesProperErrorFormatting() 140 | { 141 | $request = new Google_Http_Request("/a/b"); 142 | $request->setResponseHttpCode(401); 143 | $request->setResponseBody( 144 | '{ 145 | error: { 146 | errors: [ 147 | { 148 | "domain": "global", 149 | "reason": "authError", 150 | "message": "Invalid Credentials", 151 | "locationType": "header", 152 | "location": "Authorization", 153 | } 154 | ], 155 | "code": 401, 156 | "message": "Invalid Credentials" 157 | }' 158 | ); 159 | Google_Http_Rest::decodeHttpResponse($request); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /google-api-php-client/tests/general/ServiceTest.php: -------------------------------------------------------------------------------- 1 | mapTypes( 41 | array( 42 | 'name' => 'asdf', 43 | 'gender' => 'z', 44 | ) 45 | ); 46 | $this->assertEquals('asdf', $model->name); 47 | $this->assertEquals('z', $model->gender); 48 | $model->mapTypes( 49 | array( 50 | '__infoType' => 'Google_Model', 51 | '__infoDataType' => 'map', 52 | 'info' => array ( 53 | 'location' => 'mars', 54 | 'timezone' => 'mst', 55 | ), 56 | 'name' => 'asdf', 57 | 'gender' => 'z', 58 | ) 59 | ); 60 | $this->assertEquals('asdf', $model->name); 61 | $this->assertEquals('z', $model->gender); 62 | 63 | $this->assertEquals(false, $model->isAssociativeArray("")); 64 | $this->assertEquals(false, $model->isAssociativeArray(false)); 65 | $this->assertEquals(false, $model->isAssociativeArray(null)); 66 | $this->assertEquals(false, $model->isAssociativeArray(array())); 67 | $this->assertEquals(false, $model->isAssociativeArray(array(1, 2))); 68 | $this->assertEquals(false, $model->isAssociativeArray(array(1 => 2))); 69 | 70 | $this->assertEquals(true, $model->isAssociativeArray(array('test' => 'a'))); 71 | $this->assertEquals(true, $model->isAssociativeArray(array("a", "b" => 2))); 72 | } 73 | 74 | /** 75 | * @dataProvider serviceProvider 76 | */ 77 | public function testIncludes($class) 78 | { 79 | $this->assertTrue( 80 | class_exists($class), 81 | sprintf('Failed asserting class %s exists.', $class) 82 | ); 83 | } 84 | 85 | public function serviceProvider() 86 | { 87 | $classes = array(); 88 | $path = dirname(dirname(dirname(__FILE__))) . '/src/Google/Service'; 89 | foreach (glob($path . "/*.php") as $file) { 90 | $classes[] = array('Google_Service_' . basename($file, '.php')); 91 | } 92 | 93 | return $classes; 94 | } 95 | 96 | public function testStrLen() 97 | { 98 | $this->assertEquals(0, Google_Utils::getStrLen(null)); 99 | $this->assertEquals(0, Google_Utils::getStrLen(false)); 100 | $this->assertEquals(0, Google_Utils::getStrLen("")); 101 | 102 | $this->assertEquals(1, Google_Utils::getStrLen(" ")); 103 | $this->assertEquals(2, Google_Utils::getStrLen(" 1")); 104 | $this->assertEquals(7, Google_Utils::getStrLen("0a\\n\n\r\n")); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /google-api-php-client/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-----"} -------------------------------------------------------------------------------- /google-api-php-client/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----- -------------------------------------------------------------------------------- /google-api-php-client/tests/general/testdata/cert.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/visualbasic6/google-drive-infoleak/af3c059a914edfe427e44466fa7930e831cc37dd/google-api-php-client/tests/general/testdata/cert.p12 -------------------------------------------------------------------------------- /google-api-php-client/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----- -------------------------------------------------------------------------------- /google-api-php-client/tests/general/testdata/test.ini: -------------------------------------------------------------------------------- 1 | ; Test.ini file 2 | application_name = My Test application 3 | auth_class = Google_Auth_OAuth2 4 | [classes] 5 | Google_Auth_OAuth2[client_id] = 12345.apps.googleusercontent.com 6 | Google_Auth_OAuth2[client_secret] = gjfiwnGinpena3 7 | Google_Auth_OAuth2[redirect_uri] = http://example.com -------------------------------------------------------------------------------- /google-api-php-client/tests/general/testdata/test_public_key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDQjCCAiqgAwIBAgIJAMJ1Z12ZdGgLMA0GCSqGSIb3DQEBBQUAMB8xHTAbBgNV 3 | BAMTFHRlc3Qtc2VydmljZS1hY2NvdW50MB4XDTExMDgyMzIwNTczNFoXDTIxMDgy 4 | MDIwNTczNFowHzEdMBsGA1UEAxMUdGVzdC1zZXJ2aWNlLWFjY291bnQwggEiMA0G 5 | CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDpbFTjUXd02HFluI2G0kGKp1J5K2F8 6 | cYr7hKXHcsmKo6S/5g8AEYnnV1fEbiopoGt7UWV4T0LA99K0gqQ7QmvZKvFHXlgR 7 | XJH1aO+ZipVs3ycZOcjBMcw4hspFSi4IyQta64gASFUT5NaxRVGhzAuPlzH09dZQ 8 | RJ0NL54HccGNzEDaLx5usB8t2aRHbE4zRWJlNIsjgWnfVoiXwOv5oRhyfFMIaTu1 9 | eIp3XP1QAv5cuYS2U4ZJ+J7Gzg6E7t4PWqK7rGjnc5BJsVIoiL77K/xKUWABNgHz 10 | b6JuiEp3LX9f2H5+CKo/IJFWoyIYWdZiu69LZivife9sTXmDnOcZkisRAgMBAAGj 11 | gYAwfjAdBgNVHQ4EFgQU0RkXlevVO2zuTFP/ksFUbNkpm+kwTwYDVR0jBEgwRoAU 12 | 0RkXlevVO2zuTFP/ksFUbNkpm+mhI6QhMB8xHTAbBgNVBAMTFHRlc3Qtc2Vydmlj 13 | ZS1hY2NvdW50ggkAwnVnXZl0aAswDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUF 14 | AAOCAQEAT+3VKautn+uV7ZQWbfx6xrGaDZ5wVK9FWOTVKsjdXyp11jtoVkDONLz5 15 | 3J7wgppZWabPargIZUHe9/P6j7QTgNV2na2thGHtVRIRyDECnVrvhCn/IDpMeJjj 16 | IAuysmSITHGEwb4AvRC5HdqfWzBqAvRhjJ2crcHZpx5/KkYZgJz9ylGJCynxpbHU 17 | 1aRu4qpkQNB4t4z5EzNOSLkFw9vEtm0hNX76CsNJFd0XDEKDQI2Lsc0WfDzQ1ZQH 18 | UVzIoTmQDkYGylQOBVyxZoGI6fuSo8c2I1BKvsdBGhSPjePNvaKUbmLSwUsranhX 19 | 2Y1kn7xbDTUHymZ0+g5rDM9kWmhZfg== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /google-api-php-client/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); 37 | $this->assertInstanceOf('Google_Service_Pagespeedonline_ResultPageStats', $result->pageStats); 38 | $this->assertArrayHasKey('minor', $result['version']); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /google-api-php-client/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 | -------------------------------------------------------------------------------- /google-api-php-client/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 | -------------------------------------------------------------------------------- /google-api-php-client/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 | -------------------------------------------------------------------------------- /google-api-php-client/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 | -------------------------------------------------------------------------------- /index_files/formoid1/.htaccess: -------------------------------------------------------------------------------- 1 |