Display & Video 360 服務
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您可以使用 Display & Video 360 (DV360) 服務,在 Apps Script 中使用 DV360 API。這個 API 提供 Display & Video API 的程式輔助存取權。
參考資料
如要進一步瞭解這項服務,請參閱 DV360 API 的參考說明文件。與 Apps Script 中的所有進階服務一樣,DV360 服務使用的物件、方法和參數都與公開 API 相同。詳情請參閱「如何判斷方法簽章」。
如要回報問題及尋求其他支援,請參閱 DV360 支援指南。
程式碼範例
下列程式碼範例使用 API 的第 4 版。
查看合作夥伴清單
這個範例會記錄帳戶中所有可用的合作夥伴。
取得有效廣告活動清單
這個範例會記錄所有有效廣告活動的名稱和 ID。請注意,使用分頁符記可擷取完整清單。
更新委刊項的顯示名稱
這個範例會更新委刊項的顯示名稱
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[],[],null,["# Display & Video 360 Service\n\nThe Display \\& Video 360 (DV360) service lets you use the\n[DV360 API](/display-video)\nin Apps Script. This API provides programmatic access to the Display \\& Video API.\n| **Note:** This is an advanced service that must be [enabled before use](/apps-script/guides/services/advanced).\n\nReference\n---------\n\nFor detailed information on this service, see the\n[reference documentation](/display-video/api/reference/rest) for the\nDV360 API. Like all advanced services in Apps\nScript, the DV360 service uses the same objects, methods, and\nparameters as the public API. For more information, see [How method signatures are determined](/apps-script/guides/services/advanced#how_method_signatures_are_determined).\n\nTo report issues and find other support, see the\n[DV360 support guide](/display-video/api/support).\n\nSample code\n-----------\n\nThe following sample code uses\n[version 4](/display-video/api/reference/rest/v4) of the API.\n\n### Get a list of partners\n\nThis sample logs all of the partners available in the account. \nadvanced/displayvideo.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/displayvideo.gs) \n\n```javascript\n/**\n * Logs all of the partners available in the account.\n */\nfunction listPartners() {\n // Retrieve the list of available partners\n try {\n const partners = DisplayVideo.Partners.list();\n\n if (partners.partners) {\n // Print out the ID and name of each\n for (let i = 0; i \u003c partners.partners.length; i++) {\n const partner = partners.partners[i];\n console.log('Found partner with ID %s and name \"%s\".',\n partner.partnerId, partner.displayName);\n }\n }\n } catch (e) {\n // TODO (Developer) - Handle exception\n console.log('Failed with error: %s', e.error);\n }\n}\n```\n\n### Get a list of active campaigns\n\nThis sample logs names and IDs of all active campaigns. Note the use of\npaging tokens to retrieve the whole list. \nadvanced/displayvideo.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/displayvideo.gs) \n\n```javascript\n/**\n * Logs names and ID's of all active campaigns.\n * Note the use of paging tokens to retrieve the whole list.\n */\nfunction listActiveCampaigns() {\n const advertiserId = '1234567'; // Replace with your advertiser ID.\n let result;\n let pageToken;\n try {\n do {\n result = DisplayVideo.Advertisers.Campaigns.list(advertiserId, {\n 'filter': 'entityStatus=\"ENTITY_STATUS_ACTIVE\"',\n 'pageToken': pageToken\n });\n if (result.campaigns) {\n for (let i = 0; i \u003c result.campaigns.length; i++) {\n const campaign = result.campaigns[i];\n console.log('Found campaign with ID %s and name \"%s\".',\n campaign.campaignId, campaign.displayName);\n }\n }\n pageToken = result.nextPageToken;\n } while (pageToken);\n } catch (e) {\n // TODO (Developer) - Handle exception\n console.log('Failed with error: %s', e.error);\n }\n}\n```\n\n### Update the display name of a line item\n\nThis sample updates the display name of a line item \nadvanced/displayvideo.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/displayvideo.gs) \n\n```javascript\n/**\n * Updates the display name of a line item\n */\nfunction updateLineItemName() {\n const advertiserId = '1234567'; // Replace with your advertiser ID.\n const lineItemId = '123456789'; //Replace with your line item ID.\n const updateMask = \"displayName\";\n\n const lineItemDef = {displayName: 'New Line Item Name (updated from Apps Script!)'};\n\n try {\n const lineItem = DisplayVideo.Advertisers.LineItems\n .patch(lineItemDef, advertiserId, lineItemId, {updateMask:updateMask});\n\n\n } catch (e) {\n // TODO (Developer) - Handle exception\n console.log('Failed with error: %s', e.error);\n }\n}\n```"]]