想分享對 Google Ads API 的意見嗎?
立即註冊,等待受邀參與使用者研究調查!
查詢公用程式
使用 API 時,如要擷取對 proto 類別的參照,您必須對 API 有內在的瞭解,或是需要經常查詢 proto 參考說明文件,才能取得確切路徑。
ProtoLookupUtil
您可以使用 proto 查詢工具,查詢及建立服務、作業、列舉和資源的例項,而無須追蹤 API 版本號碼和命名空間。
以下是一般建立廣告活動的方法:
campaign = Google::Ads::GoogleAds::V19::Resources::Campaign.new
不過,您可以使用 proto 查詢公用程式,以更簡單的形式進行:
campaign = client.resource.campaign
擷取資源、服務或作業時,系統會傳回該實體的例項。擷取列舉時,系統會傳回類別的參照,但不會執行例項化。
對於列舉,您可以使用捷徑,無須查詢列舉原型。
campaign.status = :PAUSED
即使您不會將此公用程式用於其他用途,仍建議您使用 client.service
方法擷取服務。這個方法內建額外的邏輯,可傳遞開發人員權杖和驗證詳細資料,如果您使用其他方法,就必須手動處理這些資料。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-03-04 (世界標準時間)。
[null,null,["上次更新時間:2025-03-04 (世界標準時間)。"],[[["The ProtoLookupUtil simplifies interactions with the Google Ads API by removing the need to specify API version numbers and namespaces when working with services, operations, enumerations, and resources."],["Instead of manually instantiating proto classes with complex paths, the utility allows you to create and access them using a more concise and intuitive syntax, such as `client.resource.campaign` instead of `Google::Ads::GoogleAds::V18::Resources::Campaign.new`."],["It offers a shortcut for using enumerations directly, like assigning `:PAUSED` to a campaign status, without requiring explicit proto lookups."],["Using `client.service` is recommended for fetching services, as it automatically handles developer token and authentication details."]]],[]]