oauth - PHP Google Adwords API 获取广告系列
问题描述
我正在使用 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 服务?
解决方案
在您的示例的第 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
推荐阅读
- laravel - 为订阅添加付款方式时出现资源缺失错误
- javascript - ngx 拖放 - 取消绑定鼠标事件
- python - 我一次又一次得到这个错误,请告诉我为什么
- reactjs - 我将我的状态作为道具传递,但它显示为空。为什么?
- google-apps-script - 未正确分配变量
- ios - Swift 5 和 Storyboard UITableViewDelegate 不显示自定义或任何其他样式内容
- authentication - JBOSS 自定义登录模块
- python - 如何根据条件生成 2**40 个可能的二进制数
- c# - HTML 下载链接不会从 Visual Studio 19 中的服务器下载文件
- css - 如何将元素的左侧部分围绕 y 轴旋转 25 度