Giter Site home page Giter Site logo

kingjay66 / google-ads-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googleads/google-ads-php

0.0 1.0 0.0 28.57 MB

Google Ads API Client Library for PHP

Home Page: https://developers.google.com/google-ads/api/docs/client-libs/php

License: Apache License 2.0

Shell 0.01% PHP 99.98% Dockerfile 0.01%

google-ads-php's Introduction

Google Ads API Client Library for PHP

Minimum PHP Version Latest Stable Version Total Downloads License

Build Status codecov

This project hosts the PHP client library for the Google Ads API.

Features

  • Distributed via Composer and Packagist.
  • Easy management of credentials.
  • Easy creation of Google Ads API service clients.

Requirements

  • Both 32-bit and 64-bit PHP systems are supported but we highly recommend to use 64-bit if you can. This is because many fields of the Google Ads API are typed as 64-bit integers and casting their values to int instead of float from 32-bit systems can lead to issues. The largest integer value supported in 32-bit PHP systems is usually 2147483647, see the predefined constant PHP_INT_MAX for more details.
  • This library depends on Composer. If you don't have it installed on your computer yet, follow the installation guide for Linux/Unix/OS X or installation guide for Windows. For the rest of this guide, we're assuming that you're using Linux/Unix/OS X and have Composer installed globally, thus, your installed Composer is available on the command line as composer.
  • System requirements and dependencies can be found in composer.json of this library.
    • PHP: You can find the required minimum PHP version in "php" under the require key of composer.json. We usually set it to the minimum PHP version for which the PHP development team still provide security fixes. Whenever such a version is sunset, we'll update the composer file accordingly. Currently, the update frequency is around once a year based on the official schedule. Visit this page for introduction to PHP.
    • gRPC: To install the gRPC PHP extension, make sure to meet any additional requirements listed in the project's documentation. You can learn more about how gRPC is used by this library by reading our Transport guide. It usually take minutes to install using PECL:
      1. Install the extension using the command sudo pecl install grpc.
      2. Add a line extension=grpc.so to the php.ini file.
      3. Run php -i | grep grpc in a terminal: it is well installed and configured if it returns something
    • Protobuf: To install the Protobuf PHP extension, make sure to meet any additional requirements listed in the project's documentation. If you encounter any error during the installation, you can skip this step and the PHP implementation will be used instead. You can learn more about how Protobuf is used by this library by reading our Protobuf implementations guide. It usually take minutes to install using PECL:
      1. Install the extension using the command sudo pecl install protobuf.
      2. Add a line extension=protobuf.so to the php.ini file.
      3. Run php -i | grep protobuf in a terminal: it is well installed and configured if it returns something
  • You need a developer token to connect to the Google Ads API.
  • One version of the library typically supports multiple versions of the Google Ads API. You can check the CHANGELOG.md file to identify what versions of the library added or removed the support for a specific version of the Google Ads API. For example, the version V7 of the Google Ads API was added in the version v9.0.0 of the library as described here.

Getting started

Running code examples

Follow the below steps if you want to try our code examples.

  1. Clone this project in the directory of your choice via:

    git clone https://github.com/googleads/google-ads-php.git
    
  2. Change into the google-ads-php directory.

    cd google-ads-php
    

    You'll see some files and subdirectories:

    • composer.json: the composer file, which holds the requirements of this library.
    • src: source code of the library.
    • tests: tests of the library code.
    • examples: many examples that demonstrate how to use the library to execute common use cases via the Google Ads API.
    • metadata: some metadata files used internally by the source code. They're automatically generated files, so you shouldn't modify them.
  3. Run composer install at the command prompt. This will install all dependencies needed for using the library and running examples.

  4. Set up your OAuth2 credentials.

    The Google Ads API uses OAuth2 as the authentication mechanism. Choose the appropriate option below based on your use case, and read and follow the instructions that the example prints to the console.

  5. Run the GetCampaigns example to test if your credentials are valid. You also need to pass your Google Ads account's customer ID without dashes as a command-line parameter:

    php examples/BasicOperations/GetCampaigns.php --customerId <YOUR_CUSTOMER_ID>
    

    NOTE: Code examples are meant to be run from command prompt, not via the web browsers.

  6. Explore other examples.

    The examples directory contains several useful examples. Most of the examples require parameters. You can see what are required by running code examples with --help as a command-line parameter.

    Note: You will find comments with the formats [START...] and [END...] in the source code of these examples. These are only used for technical purposes, you can completely disregard them.

Installing the library as your project's dependency

  1. Change into the root directory of your project.
  2. Run composer require googleads/google-ads-php at the command prompt. This will install this library and all its dependencies in the vendor/ directory of your project's root directory.
  3. Set up your OAuth2 credentials like described in the previous section.
  4. You can now use this library by importing its classes like shown in the code examples.

Basic usage

Instantiate a client

To issue requests via the Google Ads API, you first need to create a GoogleAdsClient.

For more information on how to configure a client when instantiating it, see the configuration guide.

Get a service client

Once you have an instance of GoogleAdsClient, you can obtain a service client for a particular service using one of the get...ServiceClient() methods.

Client configuration

See the Configuration guide.

Transport

There are different types of transport that can be used. See the Transport guide for more information.

Protobuf

Protobuf is used regardless of the transport used to request the Google Ads API.

See the Protobuf guide for more information.

Running in a Docker container

See the Running in a Docker container guide.

Logging

See the Logging guide.

Proxy configuration

See the Proxy guide.

Performance

See the Performance guide.

Miscellaneous

Wiki

Issue tracker

API Documentation:

Support forum

Authors

google-ads-php's People

Contributors

fiboknacky avatar pierrickvoulet avatar raibaz avatar dependabot[bot] avatar alexeyshockov avatar jradcliff avatar stevenberger avatar friedenberg avatar michaelbausor avatar kurorido avatar imerenanu avatar willemverspyck avatar neverage avatar ujwaldhakal avatar oniltos avatar n-gibs avatar mehmetcoban avatar makstech avatar mackenziestarr avatar wfansh avatar benrkarl avatar bbsnly avatar akshayagarwal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

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

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

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

  • D3 photo D3

    Data-Driven Documents codes.