設定 Proxy

如需透過 Proxy 伺服器連線至 Google Ads API,您可以使用 googleads.properties 檔案,或在應用程式程式碼中,以程式輔助方式設定 Perl 用戶端程式庫。

使用 googleads.properties

您可以在 googleads.properties 檔案的 Network Connection 區段中設定 proxy 屬性:

### Network Connection ###

# Optional proxy server URL to be used for internet connectivity.
# If your proxy connection requires authentication, make sure to include it in
# the URL, for example: http://user:password@proxy_hostname:8080
proxy=INSERT_PROXY_HERE

例如,您可以將 http://user:pass@localhost:8082 指定為 Proxy。

程式輔助設定

或者,您也可以透過程式輔助方式調整 Proxy 設定,就像調整其他設定一樣:

my $api_client = Google::Ads::GoogleAds::Client->new({
  proxy => "INSERT_PROXY_HERE",
});

您也可以設定 GOOGLE_ADS_PERL_PROXY 環境變數,並使用 $api_client->configure_from_environment_variables() 載入:

export GOOGLE_ADS_PERL_PROXY=http://user:password@proxy_hostname:8080