使用 api 创建 adwords 广告系列时出错

Error when creating adwords campign using api

我正在使用 google adwords api 通过添加广告系列名称、关键字、预算等直接从 wordpress post 或页面创建广告系列

$campaignService = $adWordsServices->get($session, CampaignService::class);
        $campaignService->SetClientId( 'xxxxxxxxxx' );
        $operations = [];

        // Create a campaign with required and optional settings.
        $campaign = new Campaign();
        $campaign->setName('Interplanetary Cruise #' . uniqid());
        $campaign->setAdvertisingChannelType(AdvertisingChannelType::SEARCH);

但是我遇到了下一个错误:

[OperationAccessDenied.ADD_OPERATION_NOT_PERMITTED @ operations[0], OperationAccessDenied.ADD_OPERATION_NOT_PERMITTED @ operations[1]]

似乎我们需要为此设置客户 ID,所以我们使用 SetClientId() 但它给出了另一个错误

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

如果您想 change/set clientCustomerId 与 php sdk,您必须在创建 Adwords 会话时这样做:

$session = (new AdWordsSessionBuilder())
    ->fromFile()
    ->withOAuth2Credential($oAuth2Credential)
    ->withClientCustomerId(clientCustomerId)
    ->build();