Điều kiện tiên quyết
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.
Trước khi bạn có thể bắt đầu lập trình ứng dụng đầu tiên của mình, có một số
những việc cần làm nếu bạn chưa thực hiện.
Tạo tài khoản Google
Bạn cần có một Tài khoản Google để tạo dự án trong Bảng điều khiển API của Google. Nếu đã có tài khoản thì bạn đã hoàn tất.
Bạn cũng nên có một Tài khoản Google riêng cho mục đích thử nghiệm.
Dùng thử Google AdMob
Tài liệu về API này giả định rằng bạn đã sử dụng Google AdMob và bạn đã quen thuộc với các khái niệm lập trình web cũng như định dạng dữ liệu web.
Nếu bạn chưa từng sử dụng Google AdMob, thì hãy thử giao diện người dùng trước khi bắt đầu lập trình.
Tạo một dự án cho ứng dụng của bạn
Trước khi có thể gửi yêu cầu đến Google AdMob, bạn cần cho Google biết về khách hàng của mình và kích hoạt quyền truy cập vào API. Bạn có thể thực hiện việc này bằng cách sử dụng Bảng điều khiển API của Google để tạo dự án. Đây là tập hợp các chế độ cài đặt và thông tin về quyền truy cập vào API được đặt tên, đồng thời đăng ký ứng dụng của bạn.
Để bắt đầu sử dụng API AdMob, trước tiên, bạn cần
sử dụng
công cụ thiết lập. Công cụ này sẽ hướng dẫn bạn tạo dự án trong
Google API Console, bật API và tạo thông tin đăng nhập.
Tìm hiểu kiến thức cơ bản về REST
REST là một kiểu kiến trúc phần mềm mang lại cách tiếp cận thuận tiện và nhất quán để yêu cầu và sửa đổi dữ liệu.
Thuật ngữ REST là viết tắt của "Đại diện chuyển trạng thái". Trong ngữ cảnh của API Google, nó đề cập đến việc sử dụng các động từ HTTP để truy xuất và sửa đổi bản trình bày dữ liệu do Google lưu trữ.
Trong hệ thống RESTful, các tài nguyên được lưu trữ trong một kho dữ liệu; ứng dụng gửi yêu cầu mà máy chủ thực hiện một hành động cụ thể (chẳng hạn như tạo, truy xuất, cập nhật hoặc xoá tài nguyên), sau đó máy chủ thực hiện hành động đó và gửi phản hồi, thường ở dạng biểu diễn tài nguyên được chỉ định.
Trong API RESTful của Google, ứng dụng chỉ định một hành động bằng cách sử dụng động từ HTTP như POST
, GET
, PUT
hoặc DELETE
. Phương thức này chỉ định tài nguyên bằng một URI duy nhất trên toàn hệ thống có dạng sau:
https://www.googleapis.com/apiName/apiVersion/resourcePath?parameters
Vì mọi tài nguyên API đều có URI riêng biệt có thể truy cập HTTP, nên REST cho phép lưu dữ liệu vào bộ nhớ đệm và được tối ưu hoá để hoạt động với cơ sở hạ tầng phân phối của web.
Bạn có thể thấy định nghĩa về phương thức trong tài liệu về các tiêu chuẩn HTTP 1.1 hữu ích; chúng bao gồm thông số kỹ thuật cho GET
, POST
, PUT
và DELETE
.
REST trong API AdMob
Các hoạt động của API AdMob liên kết trực tiếp đến các động từ HTTP REST.
Các định dạng cụ thể cho URI API của AdMob là:
https://admob.googleapis.com/v1/resourcePath?parameters
Bạn có thể thấy tóm tắt toàn bộ URI dùng cho từng thao tác được hỗ trợ trong API trong tài liệu Tài liệu tham khảo về API của AdMob.
Tìm hiểu kiến thức cơ bản về JSON
API AdMob trả về dữ liệu ở định dạng JSON.
JSON (Ký hiệu đối tượng JavaScript) là một định dạng dữ liệu phổ biến, không phụ thuộc vào ngôn ngữ, cung cấp bản trình bày văn bản đơn giản của các cấu trúc dữ liệu tùy ý. Để biết thêm thông tin, hãy xem json.org.
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.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eBefore coding, you need a Google Account (potentially a separate one for testing) and familiarity with Google AdMob.\u003c/p\u003e\n"],["\u003cp\u003eYou must create a project in the Google API Console using the provided setup tool to enable API access for your client application.\u003c/p\u003e\n"],["\u003cp\u003eThe AdMob API utilizes RESTful architecture, meaning you should understand basic REST principles and HTTP verbs for interacting with resources.\u003c/p\u003e\n"],["\u003cp\u003eData is exchanged in JSON format, so familiarity with JSON structure and parsing is beneficial.\u003c/p\u003e\n"]]],[],null,["# Prerequisites\n\nBefore you can start coding your first client application, there are a few\nthings you need to do, if you haven't done them already.\n\nGet a Google Account\n--------------------\n\nYou need a [Google Account](https://www.google.com/accounts/NewAccount) in order to [create a project](#project) in the Google API Console. If you already have an account, then you're all set.\n\nYou might also want a separate Google Account for testing purposes.\n\nTry out Google AdMob\n--------------------\n\nThis API documentation assumes that you've used Google AdMob, and that you're familiar with web programming concepts and web data formats.\n\nIf you haven't used Google AdMob, then try out the [user interface](https://admob.google.com) before starting to code.\n\nCreate a project for your client\n--------------------------------\n\nBefore you can send requests to Google AdMob, you need to tell Google about your client and activate access to the API. You do this by using the Google API Console to create a project, which is a named collection of settings and API access information, and register your application.\n\nTo get started using AdMob API, you need to first\n[use\nthe setup tool](https://console.cloud.google.com/start/api?id=admob.googleapis.com&credential=client_key), which guides you through creating a project in the\nGoogle API Console, enabling the API, and creating credentials.\n\nLearn REST basics\n-----------------\n\nREST is a style of software architecture that provides a convenient and consistent approach to requesting and modifying data.\n\nThe term REST is short for \"[Representational State Transfer](https://en.wikipedia.org/wiki/Representational_state_transfer).\" In the context of Google APIs, it refers to using HTTP verbs to retrieve and modify representations of data stored by Google.\n\nIn a RESTful system, resources are stored in a data store; a client sends a request that the server perform a particular action (such as creating, retrieving, updating, or deleting a resource), and the server performs the action and sends a response, often in the form of a representation of the specified resource.\n\nIn Google's RESTful APIs, the client specifies an action using an HTTP verb such as `POST`, `GET`, `PUT`, or `DELETE`. It specifies a resource by a globally-unique URI of the following form: \n\n```\nhttps://www.googleapis.com/apiName/apiVersion/resourcePath?parameters\n```\n\nBecause all API resources have unique HTTP-accessible URIs, REST enables data caching and is optimized to work with the web's distributed infrastructure.\n\nYou may find the [method definitions](https://tools.ietf.org/html/rfc7231#section-4.3) in the HTTP 1.1 standards documentation useful; they include specifications for `GET`, `POST`, `PUT`, and `DELETE`.\n\n### REST in the AdMob API\n\nThe AdMob API operations map directly to REST HTTP verbs.\n\nThe specific formats for AdMob API URIs are: \n\n```\nhttps://admob.googleapis.com/v1/resourcePath?parameters\n```\n\nThe full set of URIs used for each supported operation in the API is summarized in the [AdMob API Reference](/admob/api/v1/reference/rest) document.\n\nLearn JSON basics\n-----------------\n\nThe AdMob API returns data in JSON format.\n\n\n[JSON](http://en.wikipedia.org/wiki/JSON) (JavaScript Object Notation) is a common, language-independent data format that provides a simple text representation of arbitrary data structures. For more information, see [json.org](http://www.json.org/).\n\n\u003cbr /\u003e"]]