Nguồn quảng cáo
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
API AdMob cho phép bạn xem các nguồn quảng cáo dàn xếp
theo phương thức lập trình. Xem
accounts.adSources.list
để biết thêm thông tin.
Yêu cầu bằng Curl
Tải tệp mật khẩu ứng dụng khách và tạo lệnh uỷ quyền
thông tin xác thực.
Vào lần đầu tiên thực hiện bước này, bạn sẽ được yêu cầu chấp nhận một
trong trình duyệt của bạn. Trước khi chấp nhận, hãy đảm bảo bạn
đăng nhập bằng Tài khoản Google có quyền truy cập vào API AdMob. Thông tin
sẽ được phép truy cập vào dữ liệu thay mặt cho bất kỳ tài khoản nào
hiện đang đăng nhập.
Để xác thực và uỷ quyền, bạn nên sử dụng
oauth2l, một công cụ dòng lệnh đơn giản dành cho
hoạt động với Google OAuth 2.0. Cài đặt oauth2l và chạy
bên dưới, thay thế path_to_credentials_json bằng một đường dẫn
vào tệp credentials.json
mà bạn tải xuống khi đăng ký
đám mây. Trong lần chạy đầu tiên, lệnh này sẽ hướng dẫn bạn qua
Quy trình uỷ quyền OAuth 2.0. Các lần chạy tiếp theo sẽ làm mới mã thông báo
tự động.
oauth2l header --json path_to_credentials_json --scope admob.readonly
Liệt kê các nguồn quảng cáo.
Nhận thông tin về nguồn quảng cáo AdMob bằng cách thay thế pub-XXXXXXXXXXXXXXXX
bằng mã nhà xuất bản của bạn. Xem
hướng dẫn về cách tìm
mã nhà xuất bản của bạn.
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)"
Câu trả lời mẫu:
{
"adSources": [
{
"name": "accounts/pub-XXXXXXXXXXXXXXXX/adSources/5450213213286189855",
"adSourceId": "5450213213286189855",
"title": "AdMob Network",
}
]
}
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-31 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\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 ```"]]