廣告來源
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
AdMob API 可讓您查看中介服務廣告來源
編寫程式詳情請見
accounts.adSources.list
敬上
。
透過 Curl 要求
載入用戶端密鑰檔案並產生授權
憑證
系統會在您第一次執行這個步驟時,要求您接受
在瀏覽器中輸入授權提示接受前,請務必確認
使用可存取 AdMob API 的 Google 帳戶登入。您的
應用程式將有權代表
目前登入的帳戶
如要進行驗證和授權,建議您使用
oauth2l 是簡便的指令列工具
才能使用 Google OAuth 2.0安裝 OAuth2l 並執行
指令,將 path_to_credentials_json 換成路徑
連結至您在註冊 SDK 時下載的 credentials.json
檔案
雲端應用程式。第一次執行時,指令會引導您逐步完成
OAuth 2.0 授權流程。之後執行時重新整理權杖
。
oauth2l header --json path_to_credentials_json --scope admob.readonly
列出廣告來源。
替換 pub-XXXXXXXXXXXXXXXX,取得 AdMob 廣告來源資訊
換成您的發布商 ID。詳情請參閱
操作說明。
您的發布商 ID
curl --http1.0 -X GET https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/adSources \
-H "$(oauth2l header --json path_to_credentials_json --scope admob.readonly)"
回應範例:
{
"adSources": [
{
"name": "accounts/pub-XXXXXXXXXXXXXXXX/adSources/5450213213286189855",
"adSourceId": "5450213213286189855",
"title": "AdMob Network",
}
]
}
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eThe AdMob API allows programmatic access to view mediation ad sources.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication and authorization are handled using OAuth 2.0, preferably through the \u003ccode\u003eoauth2l\u003c/code\u003e tool.\u003c/p\u003e\n"],["\u003cp\u003eTo list ad sources, a request using \u003ccode\u003ecurl\u003c/code\u003e is made to the AdMob API endpoint, including your publisher ID and authorization credentials.\u003c/p\u003e\n"]]],[],null,["# Ad Sources\n\nThe AdMob API lets you view [mediation ad sources](/admob/api/v1/ad-sources-reference)\nprogrammatically. See\n[`accounts.adSources.list`](/admob/api/reference/rest/v1beta/accounts.adSources/list)\nfor additional information. \n\n### Request using Curl\n\n1. Load the [client secrets file](https://console.cloud.google.com/apis/credentials) and generate authorization\n credentials.\n\n The first time you perform this step you'll be asked to accept an\n authorization prompt in your browser. Before accepting, make sure you're\n signed in with a Google Account that has access to the AdMob API. Your\n app will be authorized to access data on behalf of whichever account is\n currently signed in.\n\n For authentication and authorization, we recommend using\n [oauth2l](//github.com/google/oauth2l), a simple command-line tool for\n working with Google OAuth 2.0. Install oauth2l and run the\n command below, replacing \u003cvar translate=\"no\"\u003epath_to_credentials_json\u003c/var\u003e with a path\n to a `credentials.json` file that you download when registering your\n cloud application. For the first run, the command walks you through the\n OAuth 2.0 authorization flow. Subsequent runs refresh the token\n automatically. \n\n ```\n oauth2l header --json path_to_credentials_json --scope admob.readonly\n ```\n2. List ad sources.\n\n Get AdMob ad source information by replacing \u003cvar translate=\"no\"\u003epub-XXXXXXXXXXXXXXXX\u003c/var\u003e\n with your publisher ID. See the\n [instructions](//support.google.com/admob/answer/2784578) on how to find\n your publisher ID. \n\n ```\n curl --http1.0 -X GET https://admob.googleapis.com/v1beta/accounts/pub-XXXXXXXXXXXXXXXX/adSources \\\n -H \"$(oauth2l header --json path_to_credentials_json --scope admob.readonly)\"\n ```\n\n Sample response: \n\n ```text\n {\n \"adSources\": [\n {\n \"name\": \"accounts/pub-XXXXXXXXXXXXXXXX/adSources/5450213213286189855\",\n \"adSourceId\": \"5450213213286189855\",\n \"title\": \"AdMob Network\",\n }\n ]\n }\n ```"]]