tprog/yii2-adwords-api

Extension for use API ADWords

Installs: 81

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

dev-master 2019-04-14 16:54 UTC

This package is not auto-updated.

Last update: 2024-05-15 09:49:43 UTC


README

Extension for use API ADWords

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist tprog/yii2-adwords-api "*"

or add

"tprog/yii2-adwords-api": "*"

to the require section of your composer.json file.

Configuration

    'components' => [
    ...
        'ADwords'   => [
            'class'            => 'tprog\adwordsapi\ADwords',
            'developerToken'   => '***************',
            'server_version'   => 'v201506',
            'userAgent'        => 'You Adwords API client',
            'clientCustomerId' => '***-***-****',
            'client'           => [
                'client_id'     => '***************',
                'client_secret' => '***************',
                'refresh_token'    => '***************',
            ],
        ],
    ...

Usage

Example create new account :

        $ADwordsUser = Yii::$app->ADwords->user;

        // Get the service, which loads the required classes.
        $managedCustomerService =
            $ADwordsUser->GetService('ManagedCustomerService');

        // Create customer.
        $customer = new \ManagedCustomer();
        $customer->name = 'Account #' . uniqid();
        $customer->currencyCode = 'EUR';
        $customer->dateTimeZone = 'Europe/London';

        // Create operation.
        $operation = new \ManagedCustomerOperation();
        $operation->operator = 'ADD';
        $operation->operand = $customer;

        $operations = [$operation];

        // Make the mutate request.
        $result = $managedCustomerService->mutate($operations);

        // Display result.
        $customer = $result->value[0];
        printf("Account with customer ID '%s' was created.\n",
            $customer->customerId);