2017 © Pedro Peláez
 

library capx-google-ads

Google Ads API for Laravel forked from nikolajlovenhardt/laravel-google-ads

image

cpcstrategy/capx-google-ads

Google Ads API for Laravel forked from nikolajlovenhardt/laravel-google-ads

  • Friday, June 16, 2017
  • by cpcstrategy
  • Repository
  • 10 Watchers
  • 0 Stars
  • 3,525 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 41 Forks
  • 0 Open issues
  • 12 Versions
  • 0 % Grown

The README.md

, (*1)

Laravel 5.1+ Lumen 5.1+ Total Downloads License Build Status Code Climate Test Coverage, (*2)

Integration of googleads/googleads-php-lib in Laravel and Lumen (version >5)., (*3)

Setup

  • Run $ composer require nikolajlovenhardt/laravel-google-ads

Laravel

  • Add provider to config/app.php
'providers' => [
    LaravelGoogleAds\LaravelGoogleAdsProvider::class,
],
  • Run $ php artisan vendor:publish to publish the configuration file config/google-ads.php and insert:
    • developerToken
    • clientId & clientSecret
    • refreshToken

Lumen

  • Add provider to bootstrap/app.php
$app->register(LaravelGoogleAds\LaravelGoogleAdsProvider::class);
  • Copy vendor/nikolajlovenhardt/laravel-google-ads/config/config.php to config/google-ads.php and insert:, (*4)

    • developerToken
    • clientId & clientSecret
    • refreshToken
  • Add config to bootstrap/app.php, (*5)

$app->configure('google-ads');

Generate refresh token

This requires that the clientId and clientSecret is from a native application., (*6)

Run $ php artisan googleads:token:generate and open the authorization url. Grant access to the app, and input the access token in the console. Copy the refresh token into your configuration config/google-ads.php, (*7)

Basic usage

The following example is for AdWords, but the general code applies to all products., (*8)

<?php

namespace App\Services;

use LaravelGoogleAds\Services\AdWordsService;
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201609\cm\CampaignService;
use Google\AdsApi\AdWords\v201609\cm\OrderBy;
use Google\AdsApi\AdWords\v201609\cm\Paging;
use Google\AdsApi\AdWords\v201609\cm\Selector;

class Service
{
    /** @var AdWordsService */
    protected $adWordsService;

    /**
     * @param AdWordsService $adWordsService
     */
    public function __construct(AdWordsService $adWordsService)
    {
        $this->adWordsService = $adWordsService;
    }

    public function campaigns()
    {
        $customerClientId = 'xxx-xxx-xx';

        $campaignService = $this->adWordsService->getService(CampaignService::class, $customerClientId);

        // Create selector.
        $selector = new Selector();
        $selector->setFields(array('Id', 'Name'));
        $selector->setOrdering(array(new OrderBy('Name', 'ASCENDING')));

        // Create paging controls.
        $selector->setPaging(new Paging(0, 100));

        // Make the get request.
        $page = $campaignService->get($selector);
    }
}

Best practices

Features, requirements, support etc.

See googleads/googleads-php-lib, (*9)

Dependencies

  • googleads/googleads-php-lib hosts the PHP client library for the various SOAP-based Ads APIs (AdWords, AdExchange Buyer, and DFP) at Google.

The Versions

16/06 2017

dev-master

9999999-dev https://github.com/CPCStrategy/capx-google-ads

Google Ads API for Laravel forked from nikolajlovenhardt/laravel-google-ads

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bilal Iqbal

laravel google adwords ads capx cpcstrategy