spotonlive / laravel-google-ads

Google Ads API for Laravel
MIT License
64 stars 58 forks source link

Class Google\AdsApi\AdWords\v201806\cm\CampaignService does not exist #55

Open sanjayacloud opened 4 years ago

sanjayacloud commented 4 years ago

Hi Friends,

I am using https://github.com/spotonlive/laravel-google-ads package for Google Ads. And I got the above error. Can anyone help me to resolve this?

My code.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use LaravelGoogleAds\Services\AdWordsService;
use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201806\cm\CampaignService;
use Google\AdsApi\AdWords\v201806\cm\OrderBy;
use Google\AdsApi\AdWords\v201806\cm\Paging;
use Google\AdsApi\AdWords\v201806\cm\Selector;

class AdController extends Controller
{
    /** @var AdWordsService */
    protected $adWordsService;

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

    public function index()
    {
        $customerClientId = '697-169-9937';

        $campaignService = $this->adWordsService->getService(CampaignService::class, $customerClientId);
         dd($campaignService);
        // 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);
    }
}
matthewnessworthy commented 4 years ago

https://github.com/googleads/googleads-php-lib/releases/tag/41.0.0

Google remove that class, check for an updated version.

sanjayacloud commented 4 years ago

Is this package has updated version?

matthewnessworthy commented 4 years ago

try v201809 instead of v201806

sanjayacloud commented 4 years ago

Can i know that version included in this package ?

On Mon, Nov 4, 2019, 7:32 PM Matthew Nessworthy notifications@github.com wrote:

try v201809 instead of v201806

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/spotonlive/laravel-google-ads/issues/55?email_source=notifications&email_token=AIFFVY6UC6OOE5UL5A2OOPTQSATPFA5CNFSM4JHGJJF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC7KZZQ#issuecomment-549367014, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIFFVY2I57PEEWSZVSCAXQDQSATPFANCNFSM4JHGJJFQ .

matthewnessworthy commented 4 years ago

The version is in the https://github.com/spotonlive/laravel-google-ads/blob/master/composer.json#L27 , it's the version I linked above https://github.com/googleads/googleads-php-lib/releases/tag/41.0.0

if you replace use Google\AdsApi\AdWords\v201806 with use Google\AdsApi\AdWords\v201809, then your code should work, if not, then I'm out of ideas for you.