【问题标题】:PHP Google Adwords API get campaignsPHP Google Adwords API 获取广告系列
【发布时间】:2018-06-02 20:32:34
【问题描述】:

我正在使用 google adwords API 来连接 adwords 并列出所有的campaingns。我正在使用 OAuth 连接到 Adwords 帐户并成为 access_token 和 refresh_token,我将它们保存到数据库中。

现在我正在尝试做这个例子: https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201802/BasicOperations/GetCampaigns.php

但我的 access_token 和 refresh_token 都在数据库中,并且所有 API OAuth2 凭据都在一个配置数组中。

如何使用此凭据查询 hte google adwords 服务?

【问题讨论】:

    标签: oauth google-api google-ads-api google-api-php-client


    【解决方案1】:

    您的示例第 81 行中引用并复制到下面的 OAuth2TokenBuilder 类有几个方法可以让您设置参数,而不是从配置文件中读取它们。

    $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
    

    fromFile 方法将从配置文件中读取参数。您的新代码可能如下所示:

    $oAuth2Credential = (new OAuth2TokenBuilder())
            ->withClientId(your oauth2 client id here)
            ->withClientSecret(your oauth2 client secret here)
            ->withRefreshToken(your stored refresh token here)
            ->build();
    

    此处对 Google AdWords API 的其他一些问题进行了简要概述: https://pete-bowen.com/how-to-use-the-google-adwords-api-to-automate-adwords

    【讨论】:

    • 谢谢,这对我有帮助!干杯尼克:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-24
    • 1970-01-01
    相关资源
    最近更新 更多