Code Monkey home page Code Monkey logo

laravel-google-ads's Introduction

Google Adwords API for Laravel

Simple and easy to use API for your Google Adwords.

Installation

Type in console:
composer require edujugon/laravel-google-ads
Laravel 5.5 or higher?

Then you don't have to either register or add the alias, this package uses Package Auto-Discovery's feature, and should be available as soon as you install it via Composer.

(Only for Laravel 5.4 or minor) Register the GoogleAds service by adding it to the providers array.
'providers' => array(
        ...
        Edujugon\GoogleAds\Providers\GoogleAdsServiceProvider::class
    )
(Only for Laravel 5.4 or minor) Let's add the Alias facade, add it to the aliases array.
'aliases' => array(
        ...
        'GoogleAds' => Edujugon\GoogleAds\Facades\GoogleAds::class,
    )
Publish the package's configuration file to the application's own config directory.
php artisan vendor:publish --provider="Edujugon\GoogleAds\Providers\GoogleAdsServiceProvider" --tag="config"

The above command will generate a new file under your laravel app config folder called google-ads.php

Configuration

Update the google-ads.php file with your data.

'env' => 'test',
'production' => [
    'developerToken' => "YOUR-DEV-TOKEN",
    'clientCustomerId' => "CLIENT-CUSTOMER-ID",
    'userAgent' => "YOUR-NAME",
    'clientId' => "CLIENT-ID",
    'clientSecret' => "CLIENT-SECRET",
    'refreshToken' => "REFRESH-TOKEN"
],
'test' => [
    'developerToken' => "YOUR-DEV-TOKEN",
    'clientCustomerId' => "CLIENT-CUSTOMER-ID",
    'userAgent' => "YOUR-NAME",
    'clientId' => "CLIENT-ID",
    'clientSecret' => "CLIENT-SECRET",
    'refreshToken' => "REFRESH-TOKEN"
],

'env' key accepts one of the following values: test / production

Generate refresh token

Notice that it will take the clientID and clientSecret from google-ads.php config file based on the env value.

Type in console:

php artisan googleads:token:generate
  • Visit the URL it shows, grant access to your app and input the access token in console.
  • Then copy the fresh token in google-ads.php config file.

Remember to copy that token in the correct section (test/production).Depends on your env value.

Usage samples

Instance the main wrapper class:

$ads = new GoogleAds();

Do not forget to put at the top of the file the use statement:

use Edujugon\GoogleAds\GoogleAds;

All needed configuration data is took from google-ads.php config file. But you always may pass new values on the fly if required.

You may override the default environment value calling the env method:

$ads->env('test');

Also, you may get the env value by getEnv method:

$ads->getEnv();

If need to override the oAuth details, just call the oAuth method like so:

$ads->oAuth([
            'clientId' => 'test',
            'clientSecret' => 'test',
            'refreshToken' => 'TEST'

        ]);

Same with session. If need to override the default values on the fly, just do it by calling session method:

$ads->session([
    'developerToken' => 'token',
    'clientCustomerId' => 'id'
]);

All the above methods can be chained as follows:

$ads->env('test')
    ->oAuth([
        'clientId' => 'test',
        'clientSecret' => 'test',
        'refreshToken' => 'TEST'

    ])
    ->session([
        'developerToken' => 'token',
        'clientCustomerId' => 'id'
    ]);

Google Services

For Google Ads Services you only have to call the service method:

$ads->service(CampaignService::class);

or

$ads->service(AdGroupService::class);

or

$ads->service(AdGroupAdService::class);

or Any google ads services available under Google\AdsApi\AdWords\v201809\cm folder.

Also you can use the global helper in order the get an instance of Service.

$service = google_service(CampaignService::class)

To retrieve a list of campaigns, do like follows:

$ads->service(CampaignService::class)
    ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
    ->get();

Notice the method select is required and you have to use it in order to set the fields you wanna get from the campaign.

If need to add a condition to your search you can use the where method like follows:

$ads->service(CampaignService::class)
    ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
    ->where('Id IN [752331963,795625088]')
    ->get();
or

$ads->service(CampaignService::class)
    ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
    ->where('Id = 752331963')
    ->get();

Notice! You may also set more than one condition. Do so calling where method as many times as you need.

Available Operators:

= | != | > | >= | < | <= | IN | NOT_IN | STARTS_WITH | STARTS_WITH_IGNORE_CASE |
CONTAINS | CONTAINS_IGNORE_CASE | DOES_NOT_CONTAIN | DOES_NOT_CONTAIN_IGNORE_CASE |
CONTAINS_ANY | CONTAINS_NONE | CONTAINS_ALL

If need to limit your search you may use limit method:

$ads->service(CampaignService::class)
    ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
    ->limit(5)
    ->get();
    

Also you can order by a field:

$ads->service(CampaignService::class)
    ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
    ->orderBy('Name')
    ->limit(5)
    ->get();

Notice that the get method returns an instance of ServiceCollection. That custom collection has its own methods.

Once you have the collection, you can again filter with the where method

$campaignService = $ads->service(CampaignService::class);

$results = $campaignService->select('CampaignId','CampaignName')->get();

//You can also add any where condition on the list.
$campaign = $results->where('id',1341312);

Also you can call the set method to change any value

$campaign = $results->where('id',$this->testedCampaignId)->set('name','hello !!');

Finally you can persist those changes with the save method:

$campaign = $campaign->save();

Save method returns an array of updated elements or false if nothing updated.

Important!! notice that it will persist all elements that are in the collection.

You can get the list as illuminate collection simply calling items method.

Google Reports

To start with google reporting just call report method from the main wrapper:

$report = $ads->report();

or use the global helper like follows:

$report = google_report();

It will return an instance of Edujugon\GoogleAds\Reports\Report

Now, you have a set of method to prepare the google ads report:

$obj = $ads->report()
            ->from('CRITERIA_PERFORMANCE_REPORT')
            ->during('20170101','20170210')
            ->where('CampaignId = 752331963')
            ->select('CampaignId','AdGroupId','AdGroupName','Id', 'Criteria', 'CriteriaType','Impressions', 'Clicks', 'Cost', 'UrlCustomParameters')
            ->getAsObj();

In the above methods, the mandatory ones are from and select

Notice that in during method you have to pass the dates as a string like YearMonthDay

You may also want to set more than one condition. Use Where clause as many times as you need like follows:

$obj = $ads->report()
            ->from('CRITERIA_PERFORMANCE_REPORT')
            ->where('Clicks > 10')
            ->where('Cost > 10')
            ->where('Impressions > 1')
            ->select('CampaignId','AdGroupId','AdGroupName','Id', 'Criteria', 'CriteriaType','Impressions', 'Clicks', 'Cost', 'UrlCustomParameters')
            ->getAsObj();

Available Operators:

= | != | > | >= | < | <= | IN | NOT_IN | STARTS_WITH | STARTS_WITH_IGNORE_CASE |
CONTAINS | CONTAINS_IGNORE_CASE | DOES_NOT_CONTAIN | DOES_NOT_CONTAIN_IGNORE_CASE |
CONTAINS_ANY | CONTAINS_NONE | CONTAINS_ALL

Want to exclude any field? Just do it like follows:

$obj = $ads->report()
           ->from('SHOPPING_PERFORMANCE_REPORT')
           ->select(\Edujugon\GoogleAds\Facades\GoogleAds::fields()->of('SHOPPING_PERFORMANCE_REPORT')->asList())
           ->except('SearchImpressionShare','ExternalConversionSource','Ctr','Cost','Date','Week','Year','AverageCpc','Clicks','ClickType','ConversionCategoryName','ConversionTrackerId','ConversionTypeName')
            ->getAsObj();

If want to see the retrieve items, just get so by result property of the object returned:

$items = $obj->result;

Notice that it is a Collection. So you have all collection methods available.

If need the report in another format, just call format method before getting the report:

$string = $ads->report()
            ->format('CSVFOREXCEL')
            ->select('CampaignId','AdGroupId','AdGroupName','Id', 'Criteria', 'CriteriaType','Impressions', 'Clicks', 'Cost', 'UrlCustomParameters')
            ->from('CRITERIA_PERFORMANCE_REPORT')
            ->getAsString();

To see the available report formats:

$ads->report()->getFormats()

To see what fields are available for a specific report type you can do like follows:

$fields = $ads->report()->from('CRITERIA_PERFORMANCE_REPORT')->getFields();

If want to know what report types are available, just do like follow:

$ads->report()->getTypes();

There are 3 output formats for the report. It can be as object, as stream, as string.

getAsString();
getStream();
getAsObj();

Also you can save the report in a file:

$saved = $ads->report()
             ->select('CampaignId','AdGroupId','AdGroupName','Id', 'Criteria', 'CriteriaType','Impressions', 'Clicks', 'Cost', 'UrlCustomParameters')
             ->from('CRITERIA_PERFORMANCE_REPORT')
             ->saveToFile($filePath)

The above code will create a file in the passed path returning true if everything was fine.

API Documentation

Full API List

laravel-google-ads's People

Contributors

edujugon avatar jeremydunn avatar ltkort avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-google-ads's Issues

AuthenticationError.OAUTH_TOKEN_INVALID

Gettting this error, this is the google-ads.php.

It says OAUTH_TOKEN_INVALID.

<?php
return [
    //Environment=> test/production
    'env' => 'test',
    //Google Ads
    'production' => [
        'developerToken' => "0HZ-----------R7g",
        'clientCustomerId' => "10--------8",
        'userAgent' => "Name",
        'clientId' => "92----------.apps.googleusercontent.com",
        'clientSecret' => "9II---------Kr",
        'refreshToken' => "1/-----------------M"
    ],
    'test' => [
        'developerToken' => "0HZ-----------R7g",
        'clientCustomerId' => "10--------8",
        'userAgent' => "Name",
        'clientId' => "92----------.apps.googleusercontent.com",
        'clientSecret' => "9II---------Kr",
        'refreshToken' => "1/-----------------M"
    ],
    'oAuth2' => [
        'authorizationUri' => 'https://accounts.google.com/o/oauth2/v2/auth',
        'redirectUri' => 'urn:ietf:wg:oauth:2.0:oob',
        'tokenCredentialUri' => 'https://www.googleapis.com/oauth2/v4/token',
        'scope' => 'https://www.googleapis.com/auth/adwords'
    ]
];

And this is my code to fetch the reports

$ads = new GoogleAds();
        $ads->env('test');
        $report = $ads->report();
        $obj = $ads->report()
            ->from('CRITERIA_PERFORMANCE_REPORT')
            ->where('Clicks > 10')
            ->where('Cost > 10')
            ->where('Impressions > 1')
            ->select('CampaignId','AdGroupId','AdGroupName','Id', 'Criteria', 'CriteriaType','Impressions', 'Clicks', 'Cost', 'UrlCustomParameters')
            ->getAsObj();
        print_r($ads);die;

I have got refresh token from oauth playground
running this command php artisan googleads:token:generate gives error
Please provide a valid configuration for Laravel Google Ads

Question on not using the php artisan googleads:token:generate command

Hi, I'm was trying to use the console command for getting the refresh token but I was always getting errors about the "token redeemed". I always used new Authorization code, following all the process again just like this https://developers.google.com/adwords/api/docs/guides/authentication#configure_and_use_a_client_library

But then I realized that I was trying to generate a refresh token... but the OAuth 2.0 Playground site was generating it by the console.. SO, I went, take that refresh token and put it on the google-ads.php file... so it seems to work, the only issue is that now when I'm trying to make a request via Laravel controller, just like your examples, I get this

[QuotaCheckError.DEVELOPER_TOKEN_NOT_APPROVED @ ; trigger:'']

I have to say that this might be truth because on the API Center of the agency's adwords account appear this (test account... )

Nivel de acceso
Cuenta de prueba
Solicitar acceso básico
open_in_new

It means... that the output of my Laravel app could be truth... what do you think?

Any ideas? should I use only the command for generate the refresh toke? thanks a lot in advanced for your help. (Sorry about the syntaxis)

Upgrade to Google API v29.0.0 ?

Hi, thank you for the great job.
Do you plan to upgrade the requirements to the latest googleads-php-lib version v29.0.0 (201708) ?

Function ("query") is not a valid method for this service

I'm getting this error when trying to call some of the services

Function ("query") is not a valid method for this service

Specifically it happens with CustomerService and ManagedCustomerService. I'm doing the following -

$results = $this->ads->service(CustomerService::class) ->select(['CustomerId']) ->get();

Is there something I'm doing wrong here?

ClientException

Client error: POST https://www.googleapis.com/oauth2/v4/token resulted in a 400 Bad Request response:
{
"error": "invalid_grant",
"error_description": "Bad Request"
}

Error: If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error

When I deploy my application to Hostgator server I get this error:
"Your application has authenticated using end user credentials from Gooogle Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/."

Any help?

Fatal Exception - unexpected 'list' (T_LIST)

Hi Eduardo!

Thanks for your great work. I just dropped it in a new project using homestead 5.4.0.
After setting up the config and generating the token successfully, I run into an error after calling just this line:

$ads = new GoogleAds();

This is the error:

Could it be a Laravel version mismatch ?

(1/1) FatalErrorException
syntax error, unexpected 'list' (T_LIST)
in GoogleAds.php (line 168)
at FatalErrorException->__construct()
in HandleExceptions.php (line 134)
at HandleExceptions->fatalExceptionFromError()
in HandleExceptions.php (line 119)
at HandleExceptions->handleShutdown()
in HandleExceptions.php (line 0)
at Composer\Autoload\includeFile()
in ClassLoader.php (line 322)
at ClassLoader->loadClass()
in Controller.php (line 28)
at spl_autoload_call()
in Controller.php (line 28)
at HomeController->show()
in Controller.php (line 55)

toJson not returning results

I am trying to return the results as json by doing

return $results->items()->toJson();

However, it is returning an empty json object.

redirect_uri_mismatch

Hi.

I got a 404 page: Error: redirect_uri_mismatch
when I request oAuth when I do

php artisan googleads:token:generate

error

can you tell me how to fix this error please

Error: redirect_uri_mismatch

The redirect URI in the request, urn:ietf:wg:oauth:2.0:oob, can only be used by a Client ID for native application. It is not allowed for the WEB client type. You can create a Client ID for native application at https://console.developers.google.com/apis/credentials/oaut

i am trying to make the connection on my local dev but when i try it returns this error.

what am i missing

Including zero impressions in reports

Hi! I've able get report from my AdWords test account. But in some cases, I need to include zero impressions in my report. Can anyone help me with this?

The service 'CampaignService' is not found

Hi.

I am using this library with Laravel 6.

  1. I have configured google-ads.php with the correct configuration. Also, update the 'refreshToken' with the new token received in the console panel.

  2. use Edujugon\GoogleAds\GoogleAds;

  3. Trying to list all the available campaign id and name.
    Getting this code snippets here and try it like this,

$response = $ads->service(CampaignService::class)
->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
->get();

  1. Receive the below error.
    Edujugon\GoogleAds\Exceptions\Service
    The service 'App\Http\Controllers\CampaignService' is not available. Please pass a valid service

Please help me to resolve the issues. Let me know if you need further information. I am waiting for your reply.

Thanks.

php artisan config:cache

I've setup my google-ads.php config file with env() helpers, because I want to follow the good practice of not putting credentials in my repo history.

However when I run php artisan config:cache, the google ads package isn't working anymore. I guess that the package is still looking in the google-ads.php file, which now returns null on each value, because when you run php artisan config:cache. The env() will always return null.

Installation request for phpdocumentor/reflection-docblock (locked at 2.0.4)

run composer require edujugon/laravel-google-ads

Getting this error

 Problem 1
    - Installation request for edujugon/laravel-google-ads ^1.5 -> satisfiable by edujugon/laravel-google-ads[1.5.0].
    - Conclusion: remove phpdocumentor/reflection-docblock 2.0.4
    - Conclusion: don't install phpdocumentor/reflection-docblock 2.0.4
    - edujugon/laravel-google-ads 1.5.0 requires googleads/googleads-php-lib ^35.0 -> satisfiable by googleads/googleads
-php-lib[35.0.0, 35.1.0].
    - googleads/googleads-php-lib 35.0.0 requires phpdocumentor/reflection-docblock ^4.0.0 || ^3.0.3 -> satisfiable by p
hpdocumentor/reflection-docblock[3.0.3, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.3.0, 3.3.2, 4.0.0, 4.0.1, 4.1.0, 4.1
.1, 4.2.0, 4.3.0].
    - googleads/googleads-php-lib 35.1.0 requires phpdocumentor/reflection-docblock ^4.0.0 || ^3.0.3 -> satisfiable by p
hpdocumentor/reflection-docblock[3.0.3, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.3.0, 3.3.2, 4.0.0, 4.0.1, 4.1.0, 4.1
.1, 4.2.0, 4.3.0].
    - Can only install one of: phpdocumentor/reflection-docblock[3.0.3, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[3.1.0, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[3.1.1, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[3.2.0, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[3.2.1, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[3.2.2, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[3.2.3, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[3.3.0, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[3.3.2, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[4.0.0, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[4.0.1, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[4.1.0, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[4.1.1, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[4.2.0, 2.0.4].
    - Can only install one of: phpdocumentor/reflection-docblock[4.3.0, 2.0.4].
    - Installation request for phpdocumentor/reflection-docblock (locked at 2.0.4) -> satisfiable by phpdocumentor/refle
ction-docblock[2.0.4].

Error require googleabs dev-master

i get an error, after install via composer

Problem 1
- Installation request for edujugon/laravel-google-ads dev-master -> satisfiable by edujugon/laravel-google-ads[dev-master].
- edujugon/laravel-google-ads dev-master requires googleads/googleads-php-lib ^31.0 -> satisfiable by googleads/googleads-php-lib[31.0.0].
- Conclusion: don't install phpdocumentor/reflection-docblock 4.x-dev
- googleads/googleads-php-lib 31.0.0 requires phpdocumentor/reflection-docblock ^3.0.3 -> satisfiable by phpdocumentor/reflection-docblock[3.0.3, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.3.0, 3.3.2].
- Can only install one of: phpdocumentor/reflection-docblock[3.0.3, 4.x-dev].
- Can only install one of: phpdocumentor/reflection-docblock[3.1.0, 4.x-dev].
- Can only install one of: phpdocumentor/reflection-docblock[3.1.1, 4.x-dev].
- Can only install one of: phpdocumentor/reflection-docblock[3.2.0, 4.x-dev].
- Can only install one of: phpdocumentor/reflection-docblock[3.2.1, 4.x-dev].
- Can only install one of: phpdocumentor/reflection-docblock[3.2.2, 4.x-dev].
- Can only install one of: phpdocumentor/reflection-docblock[3.2.3, 4.x-dev].
- Can only install one of: phpdocumentor/reflection-docblock[3.3.0, 4.x-dev].
- Can only install one of: phpdocumentor/reflection-docblock[3.3.2, 4.x-dev].
- Installation request for phpdocumentor/reflection-docblock (locked at 4.x-dev) -> satisfiable by phpdocumentor/reflection-docblock[4.x-dev].

How to solve guzzle error

Problem 1
- Installation request for edujugon/laravel-google-ads ^2.1 -> satisfiable by edujugon/laravel-google-ads[2.1.0].
- Can only install one of: guzzlehttp/guzzle[6.5.x-dev, 7.0.1].
- Can only install one of: guzzlehttp/guzzle[7.0.1, 6.5.x-dev].
- Can only install one of: guzzlehttp/guzzle[6.5.x-dev, 7.0.1].
- Conclusion: install guzzlehttp/guzzle 6.5.x-dev
- Installation request for guzzlehttp/guzzle (locked at 7.0.1, required as ^7.0) -> satisfiable by guzzlehttp/guzzle[7.0.1].

phpdocumentor/reflection-docblock ^3.0.3

Getting this error

Problem 1
- edujugon/laravel-google-ads 1.2.1 requires googleads/googleads-php-lib ^31.0 -> satisfiable by googleads/googleads-php-lib[31.0.0].
- Installation request for edujugon/laravel-google-ads ^1.2 -> satisfiable by edujugon/laravel-google-ads[1.2.1].
- Conclusion: remove phpdocumentor/reflection-docblock 4.2.0
- Conclusion: don't install phpdocumentor/reflection-docblock 4.2.0
- googleads/googleads-php-lib 31.0.0 requires phpdocumentor/reflection-docblock ^3.0.3 -> satisfiable by phpdocumentor/reflection-docblock[3.0.3, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.3.0, 3.3.2].
- Can only install one of: phpdocumentor/reflection-docblock[3.0.3, 4.2.0].
- Can only install one of: phpdocumentor/reflection-docblock[3.1.0, 4.2.0].
- Can only install one of: phpdocumentor/reflection-docblock[3.1.1, 4.2.0].
- Can only install one of: phpdocumentor/reflection-docblock[3.2.0, 4.2.0].
- Can only install one of: phpdocumentor/reflection-docblock[3.2.1, 4.2.0].
- Can only install one of: phpdocumentor/reflection-docblock[3.2.2, 4.2.0].
- Can only install one of: phpdocumentor/reflection-docblock[3.2.3, 4.2.0].
- Can only install one of: phpdocumentor/reflection-docblock[3.3.0, 4.2.0].
- Can only install one of: phpdocumentor/reflection-docblock[3.3.2, 4.2.0].
- Installation request for phpdocumentor/reflection-docblock (locked at 4.2.0) -> satisfiable by phpdocumentor/reflection-docblock[4.2.0].

Looks like they have a fix for it - googleads/googleads-php-lib#370

Please update to a new version of adwords ?

I get this error
Details: [fieldPath: ; trigger: You are accessing an AdWords API version v201708 that has been discontinued. Calls to this version may fail. Please visit the AdWords API blog for information on migration to the new AdWords API version.; errorString: RequestError.UNSUPPORTED_VERSION]

nee to Upadate for 2021

Got this error on request :
[RequestError.UNSUPPORTED_VERSION @ ; trigger:'AdWords API which you are accessing has been discontinued. Use the new Google Ads API instead. Please visit https://ads-developers.googleblog.com/2021/04/upgrade-to-google-ads-api-from-adwords.html to get started.']

Not getting campaign list

I am trying to fetch campaign by using following code.
screenshot from 2018-10-10 14-56-29
I am getting following response after using the above code for fetching campaigns. It does not show details of campaigns list. How can I fetch proper campaign list please guide me.
screenshot_2018-10-10 screenshot

SoapFault Could not connect to host

I have filled the test config params only left the production params untouched, I get this error ! Any idea on what it might be ?

SoapFault
Could not connect to host

  <?php

namespace App\Http\Controllers;

use Edujugon\GoogleAds\GoogleAds;
use Google\AdsApi\AdWords\v201710\cm\CampaignService;

class GoogleAdwordsController extends Controller
{
    public function test()
    {
        $ads = new GoogleAds();

        $service = $ads->service(CampaignService::class)
            ->select(['Id', 'Name', 'Status', 'ServingStatus', 'StartDate', 'EndDate'])
            ->get();

        dd($service);

    }
}



I have also tried to re generate the `refreshToken` twice but not luck! 

Error while installing Edujugon / laravel-google-ads

Here is what I got
Your requirements could not be resolved to an installable set of packages.

Problem 1
- googleads/googleads-php-lib[dev-master, 49.0.0, 50.0.0, ..., 50.0.1, 52.0.0, 53.0.0, ..., 53.1.0, 54.0.0, 55.0.0] require guzzlehttp/psr7 ^1.2 -> found guzzlehttp/psr7[1.2.0, ..., 1.x-dev] but the package is fixed to 2.1.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- googleads/googleads-php-lib[37.0.0, ..., 37.1.0, 38.0.0, 39.0.0, 40.0.0, 41.0.0, 42.0.0, 43.0.0, 44.0.0, 45.0.0, 46.0.0, ..., 46.2.1, 47.0.0, 48.0.0] require guzzlehttp/guzzle ^6.0 -> found guzzlehttp/guzzle[6.0.0, ..., 6.5.x-dev] but it conflicts with your root composer.json require (^7.0.1).
- edujugon/laravel-google-ads 2.2.0 requires googleads/googleads-php-lib >=37.0 -> satisfiable by googleads/googleads-php-lib[37.0.0, 37.1.0, 38.0.0, 39.0.0, 40.0.0, 41.0.0, 42.0.0, 43.0.0, 44.0.0, 45.0.0, 46.0.0, 46.1.0, 46.2.0, 46.2.1, 47.0.0, 48.0.0, 49.0.0, 50.0.0, 50.0.1, 52.0.0, 53.0.0, 53.1.0, 54.0.0, 55.0.0].
- Root composer.json requires edujugon/laravel-google-ads ^2.2 -> satisfiable by edujugon/laravel-google-ads[2.2.0].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

**My Composer Require Section is **

"require": {
"php": "^7.3|^8.0",
"adam-paterson/oauth2-slack": "^1.1",
"aws/aws-php-sns-message-validator": "^1.6",
"aws/aws-sdk-php": "^3.204",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"infusionsoft/php-sdk": "^1.5",
"laravel/framework": "^8.65",
"laravel/tinker": "^2.5",
"league/flysystem-aws-s3-v3": "^1.0",
"league/flysystem-sftp": "~1.0",
"mailgun/mailgun-php": "^3.5",
"twilio/sdk": "^6.31"
}

Environment

Hi, how to get all these fields?

'developerToken' => "YOUR-DEV-TOKEN",
'clientCustomerId' => "CLIENT-CUSTOMER-ID",
'userAgent' => "YOUR-NAME",
'clientId' => "CLIENT-ID",
'clientSecret' => "CLIENT-SECRET",
'refreshToken' => "REFRESH-TOKEN"

Thanks

Keyword Issue

how can i use
new Predicate('AdGroupId', PredicateOperator::IN, [$adGroupId]),
new Predicate(
'CriteriaType',
PredicateOperator::IN,
[CriterionType::KEYWORD]
)

i want to get the keyword of specific adgroup

redirect_uri_mismatch

i am getting redirect_uri_mismatch error from google when i am running this command " php artisan googleads:token:generate". i don't know what i am doing wrong.

Upgrade to Google API v37.1.0?

Hi, thank you for the great job.
Do you plan to upgrade the requirements to the latest googleads-php-lib version v37.1.0 (201809)?

Get all accounts

Hi,

I'm Vergel Aranas. Currently use your package.

How to get all client/account customer Ids?

Getting ads from AdGroupAd

Just doing something basic like this -

$data = $this->ads->service(AdGroupAdService::class)
    ->select('Id', 'Name')
            ->get();
        foreach ($data->items() as $d) {
            dd($d);
        }

For some reason it only returns 1 ExpandedAdText (I have multiple ads running. Even using getAd()). That Ad only returns an id & type, it doesn't return headline1, 2, urls, etc. Is there something I'm missing here? I'm trying to get my ad group ads along with the headline and url.

usage for hiearchy accounts

hi
i have to tried to list the accounts in my mcc using:

use Edujugon\GoogleAds\GoogleAds;
use Google\AdsApi\AdWords\v201809\mcm\CustomerService;
use Edujugon\GoogleAds\Session\AdwordsSession;

$userRefreshCredentials = [
    'clientId' => config('google-ads.production.clientId'),
    'clientSecret' => config('google-ads.production.clientSecret'),
    'refreshToken' => config('google-ads.production.refreshToken')
];

$adWordsServices = new GoogleAds();
$session = (new AdwordsSession())->buildWithOAuth(config('google-ads.production.developerToken'),$userRefreshCredentials);

$managedCustomerService = $adWordsServices->service(CustomerService::class, $session)->getService();
$page = $managedCustomerService->getCustomers();

i get this response:

Argument 1 passed to Google\AdsApi\AdWords\AdWordsSessionBuilder::withOAuth2Credential() must implement interface Google\Auth\FetchAuthTokenInterface, array given, called in /home/glanaj/projects/neon/vendor/edujugon/laravel-google-ads/src/src/Session/AdwordsSession.php on line 90

AdWords API which you are accessing has been discontinued. Use the new Google Ads API instead. Please visit https://ads-developers.googleblog.com/2021/04/upgrade-to-google-ads-api-from-adwords.html

Whenever i try to get data some time getting data is OK but some time it reflecting an error
Details: [fieldPath: ; trigger: AdWords API which you are accessing has been discontinued. Use the new Google Ads API instead. Please visit https://ads-developers.googleblog.com/2021/04/upgrade-to-google-ads-api-from-adwords.html to get started.; errorString: RequestError.UNSUPPORTED_VERSION]

Assistance Please

Getting this error

Client error: `POST https://www.googleapis.com/oauth2/v4/token` resulted in a `401 Unauthorized` response: { "error": "invalid_client", "error_description": "The OAuth client was not found." }

When i try to use the developer and test info for testing while i wait for my developer token to be approved that is the error i am getting now.

my config looks like this for test.

return [
	'env' => 'test',
	//Google Ads
	'production' => [],
	'test' => [
		'developerToken' => "token",
		'clientCustomerId' => "id",
		'userAgent' => "LNCES",
		'clientId' => "id",
		'clientSecret' => "test",
		'refreshToken' => "Test"
	],
	'oAuth2' => [
		'authorizationUri' => 'https://accounts.google.com/o/oauth2/v2/auth',
		'redirectUri' => 'urn:ietf:wg:oauth:2.0:oob',
		'tokenCredentialUri' => 'https://www.googleapis.com/oauth2/v4/token',
		'scope' => 'https://www.googleapis.com/auth/adwords'
	]
];


Any help would be appreciated.

Update the google-ads.php file

Hello,

Could you please help me with how can I get the data to update the google-ads.php?

I will appreciate your help.

Thank you,

Error when getting refresh token

When i try to get the refresh token laravel throws the error : requires an authorizationUri to have been set. So i think probably was a failure of google or permissions, but its everything ok. Any ideas?

LocationCriterionService issue

package error

I am getting above error While I am using LocationCriterionService.
Also How can I retrieve data in array format from the service request . It provided with protected objects.

QuotaCheckError.DEVELOPER_TOKEN_NOT_APPROVED

Hi,

We're using a test developer token (from a production account as per Google's requirements).

We're getting the following response: QuotaCheckError.DEVELOPER_TOKEN_NOT_APPROVED

We're trying to query a test account, as we're using a developer token which only has test permissions.

Our env is set to test, and all of the auth has been completed.

We're wondering if the query is still being sent in production mode, but we can't find any evidence to suggest this. If we run the getEnv() function, it tells us it is in test mode.

Is there something we are missing? Is there anyway we can check if the query is definitely being sent as a test user?

Usage for Multiple accounts

Hi,

I have configured and using this API successfully for single account associated with an MCC account. However there is no example given and also i have tried multiple ways to associate my other clients through Oauth and use there token to get their client customer id, but I am getting permission error. Can you give me an example for this? or where I am missing?

Adding Ads & AdGroups

I see in the docs that it is possible to retrieve campaigns/adgroups/ads and then modify and save the existing object, but I don't see how to create a new adgroup or ad.
Am I missing something or is creating these entities not possible?
I tried something like this:

$text_ad = new ExpandedTextAd();
$text_ad->setHeadlinePart1($ad->headline1);
$text_ad->setHeadlinePart2($ad->headline2);
$text_ad->setDescription($ad->description);
$text_ad->setFinalUrls(array($ad->url));
$text_ad->setPath1($ad->url_path1);
$text_ad->setPath2($ad->url_path2);
$ad_group_ad = new AdGroupAd();
$ad_group_ad->setAdGroupId($ad->ad_group_id);
$ad_group_ad->setAd($text_ad);
$ad_group_ad->setStatus(AdGroupAdStatus::ENABLED);
$operation = new AdGroupAdOperation();
$operation->setOperand($ad_group_ad);
$operation->setOperator(Operator::ADD);
$operations = array();
$operations[] = $operation;
$service_collection = new ServiceCollection($this->api->service(AdGroupAdService::class), $operations);
$result = $service_collection->save();

But this returns the error:

Call to undefined method Edujugon\GoogleAds\Services\Service::mutate()
vendor/edujugon/laravel-google-ads/src/Services/ServiceCollection.php line 135

Getting this error

Google \ AdsApi \ AdWords \ v201708 \ cm \ ApiException
[QuotaCheckError.INVALID_TOKEN_HEADER @ ; trigger:'token']

Can you tell me what im doing wrong?

New Google Ads API

Upon connecting with a fresh Google Ads Api, I get the error:

Google\AdsApi\AdWords\v201809\cm\ApiException
[QuotaCheckError.INVALID_TOKEN_HEADER @ ; trigger:'New developers must use the Google Ads API.']

Does this plugin support this?

Looking forward to hear from someone :)

How to install with "googleads/googleads-php-lib": "^40.0"?

I have another package installed which uses "googleads/googleads-php-lib": "^40.0". How do I install Edujugon/laravel-google-ads with "googleads/googleads-php-lib": "^40.0" instead of [37.0.0, 40.0.0]?

PS: I really like your package.

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.