资源名称
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如果您知道与实体相关的所有相关 ID,则可以使用 ResourceNames 实用程序来构建实体的资源名称。例如,广告系列资源名称的格式为 customers/<CUSTOMER_ID>/campaigns/<CAMPAIGN_ID>
,因此如果您知道客户 ID 和广告系列 ID,就可以使用 ResourceNames
实用程序来构建完整的资源名称。
假设 $customerId
包含您的客户 ID,而 $campaignId
包含您的广告系列 ID,您可以使用 forCampaign 获取广告系列的资源名称,如下所示:
$campaignResourceName = ResourceNames::forCampaign($customerId, $campaignId)
每个实体的资源名称都由一组不同的 ID 组成。例如,广告组条件的资源名称需要客户 ID、广告组 ID 和广告组条件 ID。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-27。
[null,null,["最后更新时间 (UTC):2025-08-27。"],[[["\u003cp\u003eThe \u003ccode\u003eResourceNames\u003c/code\u003e utility helps build resource names for Google Ads entities using their respective IDs.\u003c/p\u003e\n"],["\u003cp\u003eYou need to provide the necessary IDs, like customer ID and campaign ID, to construct a specific resource name.\u003c/p\u003e\n"],["\u003cp\u003eEach Google Ads entity type has a unique set of IDs required for its resource name, such as ad group criteria needing customer ID, ad group ID, and criterion ID.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eResourceNames\u003c/code\u003e offers functions like \u003ccode\u003eforCampaign\u003c/code\u003e to easily generate resource names for specific entities.\u003c/p\u003e\n"]]],[],null,["# Resource Names\n\nThe\n[ResourceNames](https://github.com/googleads/google-ads-php/blob/HEAD/src/Google/Ads/GoogleAds/Util/V21/ResourceNames.php)\nutility is a way to construct the resource name of an entity if you know all of\nthe relevant IDs related to that entity. For example, a campaign resource name\nis in the format `customers/\u003cCUSTOMER_ID\u003e/campaigns/\u003cCAMPAIGN_ID\u003e`, so if you\nknow the customer ID and the campaign ID, you can use the `ResourceNames`\nutility to construct the full resource name.\n\nProvided that `$customerId` contains your customer ID and `$campaignId` contains\nyour campaign ID, you can use\n[forCampaign](https://github.com/googleads/google-ads-php/blob/HEAD/src/Google/Ads/GoogleAds/Util/V21/ResourceNames.php#L141)\nto get the resource name of the campaign as shown below: \n\n $campaignResourceName = ResourceNames::forCampaign($customerId, $campaignId)\n\nEach entity has a different set of IDs that composes the resource name. For\ninstance, the resource name of an ad group criterion needs a customer ID, ad\ngroup ID, and ad group criterion ID."]]