如果您需要通过 HTTP 或 HTTPS 代理服务器连接到 Google Ads API,可以在 google_ads_php.ini 文件中配置代理设置,也可以在构建客户端时以编程方式进行配置。
使用 google_ads_php.ini 进行配置
在 google_ads_php.ini 文件的 CONNECTION 部分中设置 proxy 属性:
[CONNECTION]
; Optional proxy settings to be used by requests.
; If you don't have username and password, just specify host and port.
proxy = "http://user:pass@host:port"
例如,您可以将 http://user:pass@localhost:8082 指定为代理。
以程序化方式配置
或者,您也可以在 GoogleAdsClientBuilder 上以程序化方式配置代理设置:
$googleAdsClient = (new GoogleAdsClientBuilder())
// ...
->withProxy('http://user:pass@localhost:8082')
->build();