กำหนดค่าพร็อกซี

หากต้องการเชื่อมต่อกับ Google Ads API ผ่านพร็อกซีเซิร์ฟเวอร์ คุณสามารถกำหนดค่าไลบรารีของไคลเอ็นต์ Perl โดยใช้ไฟล์ googleads.properties หรือกำหนดค่าแบบเป็นโปรแกรมในโค้ดของแอปพลิเคชัน

ใช้ googleads.properties

คุณตั้งค่าพร็อพเพอร์ตี้ proxy ได้ในส่วน Network Connection ของไฟล์ googleads.properties ดังนี้

### 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 เป็นพร็อกซีได้

การกำหนดค่าแบบเป็นโปรแกรม

หรือจะกำหนดค่าการตั้งค่าพร็อกซีแบบเป็นโปรแกรมก็ได้เช่นเดียวกับการตั้งค่าอื่นๆ ดังนี้

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