@@ -13,89 +13,140 @@ This project hosts the PHP client library for the various SOAP-based Ads APIs
1313
1414[ ![ PHP version] ( https://badge.fury.io/ph/googleads%2Fgoogleads-php-lib.svg )] ( https://badge.fury.io/ph/googleads%2Fgoogleads-php-lib ) [ ![ Build Status] ( https://travis-ci.org/googleads/googleads-php-lib.svg?branch=master )] ( https://travis-ci.org/googleads/googleads-php-lib )
1515
16- ### Getting started
17-
18- 1 . Install the latest version using [ Composer] ( https://getcomposer.org/ ) .
16+ ### Requirements and Preparation
17+
18+ * System requirements and dependencies can be found in ` composer.json ` of this
19+ library. See [ this page] ( https://getcomposer.org/doc/01-basic-usage.md ) for
20+ more details.
21+ * This library depends on [ Composer] ( https://getcomposer.org/ ) . If you don't
22+ have it installed on your computer yet, follow the
23+ [ installation guide for Linux/Unix/OS X] ( https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx )
24+ or [ installation guide for Windows] ( https://getcomposer.org/doc/00-intro.md#installation-windows ) .
25+ For the rest of this guide, we're assuming that you're using
26+ Linux/Unix/OS X and have Composer installed [ globally] ( https://getcomposer.org/doc/00-intro.md#globally ) ,
27+ thus, your installed Composer is available on the command line as ` composer ` .
28+ * To use this library to connect to AdWords API, you need an
29+ [ OAuth 2 client ID and secret] ( https://developers.google.com/adwords/api/docs/guides/first-api-call#oauth2_client_id_and_client_secret ) ,
30+ as well as a [ developer token] ( https://developers.google.com/adwords/api/docs/guides/first-api-call#developer_token ) .
31+ Make sure you've written down these credentials in advance.
1932
20- ```
21- $ php composer.phar require googleads/googleads-php-lib
22- ```
33+ ### Getting started
2334
24- 1. Copy the sample `adsapi_php.ini` for your product to your home directory and
25- fill out the required properties.
35+ Copy the sample ` adsapi_php.ini ` for your product to your
36+ [ home directory] ( https://en.wikipedia.org/wiki/Home_directory#Default_home_directory_per_operating_system )
37+ and fill out the required properties before downloading the library.
38+ This library determines the home directory of your computer by using
39+ [ ` EnvironmentalVariables::getHome() ` ] ( https://github.com/googleads/googleads-php-lib/blob/master/src/Google/AdsApi/Common/Util/EnvironmentalVariables.php#L34 ) .
2640
2741 * [AdWords
2842 adsapi_php.ini](https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/adsapi_php.ini)
2943 * [DFP
3044 adsapi_php.ini](https://github.com/googleads/googleads-php-lib/blob/master/examples/Dfp/adsapi_php.ini)
3145
32- 1. Set up your OAuth2 credentials.
46+ ### Downloading this library
3347
34- The AdWords and DoubleClick for Publishers APIs use
35- [OAuth2](https://oauth.net/2/) as the authentication mechanism. Follow the
36- appropriate guide below based on your use case.
48+ There are three ways of downloading this library as described below.
3749
38- **If you're accessing an API using your own credentials...**
50+ | Method | Target Users |
51+ | -----------------------------------------------------------------------| -------------------------------------------------------------------------------------------------------------------------------|
52+ | [ Using ` composer require ` ] ( #using-composer-require ) | Those who want to ** use this library as a third-party library** for their projects and thus example files are not needed. |
53+ | [ Using ` git clone ` ] ( #using-git-clone ) | Those who want to ** alter or contribute to this library** (e.g., submitting a pull request) or want to ** run example files** . |
54+ | [ Downloading a compressed tarball] ( #downloading-a-compressed-tarball ) | Those who only want to ** run example files** . |
3955
40- * [Using
41- AdWords](https://github.com/googleads/googleads-php-lib/wiki/API-access-using-own-credentials-\(installed-application-flow\))
42- * [Using
43- DFP](https://github.com/googleads/googleads-php-lib/wiki/API-access-using-own-credentials-\(server-to-server-flow\))
56+ #### Note
4457
45- **If you're accessing an API on behalf of clients...**
58+ * If you don't have OAuth2 credentials prior to using
59+ [ installed application flow] ( https://github.com/googleads/googleads-php-lib/wiki/API-access-using-own-credentials-(installed-application-flow) ) ,
60+ you'll need [ examples/Auth/GetRefreshToken.php] ( https://github.com/googleads/googleads-php-lib/blob/master/examples/Auth/GetRefreshToken.php ) .
61+ In this case, using ` composer require ` is not an option since there are no
62+ example files downloaded with the library.
63+ * ** Our examples are meant to be run from the command line and not as a
64+ webpage.** If you run them as a webpage, results may not be shown
65+ properly.
4666
47- * [Using AdWords or
48- DFP](https://github.com/googleads/googleads-php-lib/wiki/API-access-on-behalf-of-your-clients-\(web-flow\))
67+ ### Using composer require
4968
50- ### Running examples
69+ The steps below download this library as a third-party library for your projects.
70+ The library will be downloaded by Composer and stored under the ` vendor/ ` directory.
71+ ** Examples are NOT downloaded by this download method.**
72+
73+ 1 . Install the latest version using [ Composer] ( https://getcomposer.org/ ) .
74+
75+ ```
76+ $ composer require googleads/googleads-php-lib
77+ ```
5178
52- You have two ways of getting example files: using `git clone` or downloading a
53- compressed tarball.
79+ 1. Follow [Getting started](#getting-started) if you haven't done so.
80+ 1. Follow [Setting up your OAuth2 credentials](#setting-up-your-oauth2-credentials)
81+ if you haven't set up the credentials yet.
82+ 1. You can now use the library.
5483
55- #### Using git clone
84+ ### Using git clone
5685
5786This method is suitable for those who want to alter or contribute to
58- this library. All files in this repository will be downloaded.
87+ this library (e.g., submitting pull requests) or wish to try our examples.
88+ **All** files in this repository will be downloaded.
5989
60- 1. Run `git clone https://github.com/googleads/googleads-php-lib.git` in
61- your command prompt.
62- 1. You will get a **googleads-php-lib** directory. Navigate to it by running
90+ 1. Run `git clone https://github.com/googleads/googleads-php-lib.git` at
91+ the command prompt.
92+ 1. You'll get a **googleads-php-lib** directory. Navigate to it by running
6393 `cd googleads-php-lib`.
64- 1. Run `php composer.phar install`. This will install all dependencies needed
65- for running examples.
66- 1. Set up your `adsapi_php.ini` file if you've not done so. See steps 2 and 3
67- in [Getting Started](#getting-started) for detail.
68- 1. You can now run any examples you want. Try
69- [GetCampaigns.php](https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201705/BasicOperations/GetCampaigns.php)
94+ 1. Run `composer install` at the command prompt. This will install all
95+ dependencies needed for using the library and running examples.
96+ 1. Follow [Getting started](#getting-started) if you haven't done so.
97+ 1. Follow [Setting up your OAuth2 credentials](#setting-up-your-oauth2-credentials)
98+ if you haven't set up the credentials yet.
99+ 1. You can now use the library and run any examples you want. Try
100+ [GetCampaigns.php](https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201710/BasicOperations/GetCampaigns.php)
70101 by executing the following command:
71102
72103 ```
73- $ php examples/AdWords/v201705 /BasicOperations/GetCampaigns.php
104+ $ php examples/AdWords/v201710 /BasicOperations/GetCampaigns.php
74105 ```
75106
76- #### Downloading a compressed tarball
107+ ### Downloading a compressed tarball
77108
78109This is suitable for those who only want to try out the AdWords API with this
79110client library. The extracted directory of the tarball will contain only the
80111`examples/` directory.
81112
82- 1. In the [releases](https://github.com/googleads/googleads-php-lib/releases)
83- page, select a version you want to try. Then, under **Download**, you can
84- see the names of compressed tarballs for AdWords and DFP. Click on the name
85- of compressed tarball you want to try, e.g.,
86- **adwords-examples-vX.Y.Z.tar.gz** for AdWords.
87- 1. Extract your downloaded file to any location in your computer.
88- 1. Change to the extracted directory (such as **adwords-examples-vX.Y.Z**).
89- 1. Follow all the steps in the `README.md` file in the directory, including
90- running `php composer.phar install` and setting up `adsapi_php.ini`.
113+ 1. On the [releases page](https://github.com/googleads/googleads-php-lib/releases),
114+ select a version you want to try. Then, under **Download**, select the tarball
115+ of your choice. The name of the tarball indicates which product it belongs to,
116+ for example, **adwords-examples-vX.Y.Z.tar.gz**.
117+ 1. Extract your downloaded file to any location on your computer.
118+ 1. Navigate to the extracted directory (for example, **adwords-examples-vX.Y.Z**).
119+ 1. Run `composer install` at the command prompt. This will install all dependencies
120+ needed for using the library and running examples.
121+ 1. Follow [Getting started](#getting-started) if you haven't done so.
122+ 1. Follow [Setting up your OAuth2 credentials](#setting-up-your-oauth2-credentials)
123+ if you haven't set up the credentials yet.
911241. You can now run any examples you want. Try
92- [GetCampaigns.php](https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201705 /BasicOperations/GetCampaigns.php)
125+ [GetCampaigns.php](https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201710 /BasicOperations/GetCampaigns.php)
93126 by executing the following command:
94127
95128 ```
96- $ php examples/AdWords/v201705 /BasicOperations/GetCampaigns.php
129+ $ php examples/AdWords/v201710 /BasicOperations/GetCampaigns.php
97130 ```
98131
132+ ### Setting up your OAuth2 credentials
133+
134+ The AdWords and DoubleClick for Publishers APIs use
135+ [OAuth2](https://oauth.net/2/) as the authentication mechanism. Follow the
136+ appropriate guide below based on your use case.
137+
138+ **If you're accessing an API using your own credentials...**
139+
140+ * [Using
141+ AdWords](https://github.com/googleads/googleads-php-lib/wiki/API-access-using-own-credentials-\(installed-application-flow\))
142+ * [Using
143+ DFP](https://github.com/googleads/googleads-php-lib/wiki/API-access-using-own-credentials-\(server-to-server-flow\))
144+
145+ **If you're accessing an API on behalf of clients...**
146+
147+ * [Using AdWords or
148+ DFP](https://github.com/googleads/googleads-php-lib/wiki/API-access-on-behalf-of-your-clients-\(web-flow\))
149+
99150### Basic usage
100151
101152The best way to learn how to use this library is to review the examples for your
@@ -273,16 +324,25 @@ However, not all systems have a known CA bundle on disk (e.g. Windows). This
273324library tries to locate CA bundles on your system by using Guzzle
274325[ ` default_ca_bundle() ` ] ( https://github.com/guzzle/guzzle/blob/6.0.2/src/functions.php#L157 ) .
275326
276- If this library can't find CA bundle on your system, you will get this error
277- message:
327+ If this library can't find a CA bundle on your system, you'll get an error
328+ message similar to this:
329+
330+ ```
331+ cURL error 60: SSL certificate problem: unable to get local issuer certificate.
332+ ```
333+
334+ CA file issues can also cause an error like this:
278335
279336```
280- cURL error 60: SSL certificate problem: unable to get local issuer certificate".
337+ Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL:
338+ Couldn't load from
339+ 'https://adwords.google.com/api/adwords/cm/v201710/CampaignService?wsdl' :
340+ failed to load external entity
341+ "https://adwords.google.com/api/adwords/cm/v201710/CampaignService?wsdl
281342```
282343
283- To resolve this, manually specify your SSL CA file location with
284- SoapSettinsBuilder's
285- [ ` withSslCaFile() ` ] ( https://github.com/googleads/googleads-php-lib/blob/27.1.0/src/Google/AdsApi/Common/SoapSettingsBuilder.php#L182 ) .
344+ To remedy, see [ Steps for troubleshooting CA file issues
345+ ] ( https://github.com/googleads/googleads-php-lib/wiki/Steps-for-troubleshooting-CA-file-issues ) .
286346
287347### Documentation
288348
0 commit comments