• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/Google/H06-Nov-2021-243,392208,594

LICENSEH A D06-Nov-202110 KiB204169

README.mdH A D06-Nov-20215.5 KiB10664

autoload.phpH A D06-Nov-20211 KiB278

curlio.phpH A D06-Nov-20216.9 KiB20594

lib.phpH A D06-Nov-20211.8 KiB5416

README.md

1[![Build Status](https://travis-ci.org/google/google-api-php-client.svg)](https://travis-ci.org/google/google-api-php-client)
2
3# Google APIs Client Library for PHP #
4
5## Description ##
6The Google API Client Library enables you to work with Google APIs such as Google+, Drive, or YouTube on your server.
7
8## Beta ##
9This 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 ##
18http://developers.google.com/api-client-library/php
19
20## Installation ##
21
22For the latest installation and setup instructions, see [the documentation](https://developers.google.com/api-client-library/php/start/installation).
23
24## Basic Example ##
25See the examples/ directory for examples of the key client features.
26```PHP
27<?php
28
29  require_once 'google-api-php-client/src/Google/autoload.php'; // or wherever autoload.php is located
30
31  $client = new Google_Client();
32  $client->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'], "<br /> \n";
41  }
42
43```
44
45### Service Specific Examples ###
46
47YouTube: https://github.com/youtube/api-samples/tree/master/php
48
49## Frequently Asked Questions ##
50
51### What do I do if something isn't working? ###
52
53For 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
54
55If 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.
56
57### How do I contribute? ###
58
59We 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
60
61### I want an example of X! ###
62
63If X is a feature of the library, file away! If X is an example of using a specific service, the best place to go is to the teams for those specific APIs - our preference is to link to their examples rather than add them to the library, as they can then pin to specific versions of the library. If you have any examples for other APIs, let us know and we will happily add a link to the README above!
64
65### Why do you still support 5.2? ###
66
67When 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.
68
69### Why does Google_..._Service have weird names? ###
70
71The _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.
72
73### How do I deal with non-JSON response types? ###
74
75Some 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:
76
77```
78$opt_params = array(
79  'alt' => "json"
80);
81```
82
83### How do I set a field to null? ###
84
85The library strips out nulls from the objects sent to the Google APIs as its the default value of all of the uninitialised properties. To work around this, set the field you want to null to Google_Model::NULL_VALUE. This is a placeholder that will be replaced with a true null when sent over the wire.
86
87## Code Quality ##
88
89Run the PHPUnit tests with PHPUnit. You can configure an API key and token in BaseTest.php to run all calls, but this will require some setup on the Google Developer Console.
90
91    phpunit tests/
92
93### Coding Style
94
95To check for coding style violations, run
96
97```
98vendor/bin/phpcs src --standard=style/ruleset.xml -np
99```
100
101To automatically fix (fixable) coding style violations, run
102
103```
104vendor/bin/phpcbf src --standard=style/ruleset.xml
105```
106