简体   繁体   English

使用API​​创建AdWords Campign时出错

[英]Error when creating adwords campign using api

I'm using google adwords api to create campaign directly from wordpress post or page by adding campaign name, keywords, budget etc. 我正在使用Google AdWords api通过添加广告系列名称,关键字,预算等直接从wordpress帖子或页面创建广告系列。

$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);

But I'm having the next error: 但是我遇到了下一个错误:

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

It seems we need to set customer id for this so we are using SetClientId() but its giving another error of 似乎我们需要为此设置客户ID,因此我们正在使用SetClientId()但它给出了另一个错误

Function ("SetClientId") is not a valid method for this service 函数(“ SetClientId”)不是此服务的有效方法

If you want to change/set the clientCustomerId with php sdk you have to do so when creating Adwords Session: 如果您想使用php sdk更改/设置clientCustomerId ,则必须在创建Adwords会话时执行以下操作:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM