有兴趣分享您对 Google Ads API 的反馈吗?
注册即可获邀参与用户调研!
查找 Util
在使用该 API 时,若要提取对 proto 类的引用,您需要对该 API 有深入的了解,或者需要经常查阅 proto 参考文档以获取确切路径。
ProtoLookupUtil
借助 Proto 查找实用程序,您可以查找和创建服务、操作、枚举和资源的实例,而无需跟踪 API 版本号和命名空间。
您通常会按如下方式实例化广告系列:
campaign = Google::Ads::GoogleAds::V19::Resources::Campaign.new
不过,借助 proto 查找实用程序,您可以使用更简单的表单:
campaign = client.resource.campaign
提取资源、服务或操作时,系统会返回相应实体的实例。提取枚举时,系统会返回对类的引用,而不会进行实例化。
对于枚举,您可以使用快捷方式来绕过查找枚举 proto 的需要。
campaign.status = :PAUSED
即使您不将此实用程序用于任何其他用例,我们也建议您使用 client.service
方法提取服务。此方法内置了额外的逻辑来传递您的开发者令牌和身份验证详细信息,如果您使用其他方法,则必须手动处理这些信息。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-04。
[null,null,["最后更新时间 (UTC):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."]]],[]]