资源名称
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Google Ads API 中实体的唯一标识符称为资源
名称,并以可预测格式的字符串表示。如果您知道
资源名称的组成部分时,您可以使用此实用程序
生成最终的资源名称。
ResourceNames 类
ResourceNames
类是一种构造实体资源名称的方法
如果您知道与该实体相关的所有相关 ID。例如,
广告系列资源名称采用以下格式:
customers/{customer_id}/campaigns/{campaign_id}
如果您知道客户 ID 和广告系列 ID,就可以使用
ResourceNames
类构造完整资源名称,如下所示:
String campaignResourceName = ResourceNames.campaign(customerId, campaignId);
您也可以使用其他实体名称,这些实体名称根据不同的标识符采用不同的 ID
资源名称的最终形式
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[null,null,["最后更新时间 (UTC):2025-08-21。"],[[["\u003cp\u003eThe Google Ads API uses unique identifiers called resource names to represent entities.\u003c/p\u003e\n"],["\u003cp\u003eResource names follow a predictable format and can be generated using their components.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eResourceNames\u003c/code\u003e class allows you to construct a resource name using relevant IDs, such as customer ID and campaign ID.\u003c/p\u003e\n"],["\u003cp\u003eUsing entity names like \u003ccode\u003ecampaign\u003c/code\u003e with appropriate IDs in the \u003ccode\u003eResourceNames\u003c/code\u003e class generates the full resource name string.\u003c/p\u003e\n"]]],[],null,["# Resource Names\n\nThe unique identifier for an entity in the Google Ads API is called a resource\nname, and is represented as a string with a predictable format. If you know\nthe constituent components of a resource name, you can use this utility to\ngenerate the final resource name.\n\nResourceNames class\n-------------------\n\nThe `ResourceNames` class is a way to construct the resource name of an entity\nif you know all of the relevant IDs related to that entity. For example, a\ncampaign resource name is in the format: \n\n customers/{customer_id}/campaigns/{campaign_id}\n\nSo if you know the customer ID and the campaign ID, you can use the\n`ResourceNames` class construct the full resource name as follows: \n\n String campaignResourceName = ResourceNames.campaign(customerId, campaignId);\n\nYou can use other entity names as well, which take different IDs depending on\nthe final form of the resource name."]]