สิ่งที่ต้องดำเนินการก่อน
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ก่อนที่คุณจะสามารถเริ่มเขียนโค้ดแอปพลิเคชันไคลเอ็นต์แรกของคุณ มี
สิ่งที่คุณต้องทำ หากคุณยังไม่ได้ทำ
รับบัญชี Google
คุณต้องมีบัญชี Google เพื่อสร้างโปรเจ็กต์ในคอนโซล Google API หากมีบัญชีอยู่แล้ว คุณก็พร้อมใช้งานได้
คุณอาจต้องการบัญชี Google แยกต่างหากสำหรับวัตถุประสงค์ในการทดสอบ
ลองใช้ Google AdMob
เอกสารประกอบเกี่ยวกับ API นี้จะถือว่าคุณใช้ Google AdMob และคุ้นเคยกับแนวคิดการเขียนโปรแกรมเว็บและรูปแบบข้อมูลเว็บ
หากคุณไม่ได้ใช้ Google AdMob ให้ทดลองใช้อินเทอร์เฟซผู้ใช้ก่อนเริ่มเขียนโค้ด
สร้างโปรเจ็กต์สำหรับไคลเอ็นต์
ก่อนที่จะส่งคำขอไปยัง Google AdMob คุณต้องแจ้งให้ Google ทราบเกี่ยวกับลูกค้าและเปิดใช้งานการเข้าถึง API คุณสามารถดำเนินการได้โดยใช้คอนโซล Google API เพื่อสร้างโปรเจ็กต์ ซึ่งเป็นชุดการตั้งค่าที่มีชื่อและข้อมูลการเข้าถึง API แล้วลงทะเบียนแอปพลิเคชันของคุณ
หากต้องการเริ่มต้นใช้งาน AdMob API ก่อนอื่นคุณต้อง
ใช้
เครื่องมือตั้งค่า ซึ่งจะแนะนำขั้นตอนการสร้างโปรเจ็กต์ใน
คอนโซล Google API, การเปิดใช้ API และการสร้างข้อมูลเข้าสู่ระบบ
ดูข้อมูลพื้นฐานเกี่ยวกับ REST
REST คือรูปแบบสถาปัตยกรรมซอฟต์แวร์ที่ให้วิธีการขอและแก้ไขข้อมูลที่สะดวกและสอดคล้องกัน
คำว่า REST เป็นคำสั้นๆ ของ "Sentational State Transfer" ในบริบทของ Google APIs หมายถึงการใช้คำกริยา HTTP เพื่อดึงและแก้ไขการนำเสนอข้อมูลที่ Google จัดเก็บไว้
ในระบบ RESTful ทรัพยากรจะจัดเก็บอยู่ในพื้นที่เก็บข้อมูล ไคลเอ็นต์จะส่งคำขอเพื่อให้เซิร์ฟเวอร์ดำเนินการบางอย่าง (เช่น สร้าง เรียก อัปเดต หรือลบทรัพยากร) และเซิร์ฟเวอร์จะดำเนินการดังกล่าวและส่งการตอบกลับ ซึ่งมักอยู่ในรูปแบบเป็นตัวแทนของทรัพยากรที่ระบุ
ใน RESTful API ของ Google ไคลเอ็นต์จะระบุการทำงานโดยใช้คำกริยา HTTP เช่น POST
, GET
, PUT
หรือ DELETE
โดยจะระบุทรัพยากรตาม URI ที่ไม่ซ้ำกันทั่วโลกในรูปแบบต่อไปนี้
https://www.googleapis.com/apiName/apiVersion/resourcePath?parameters
เนื่องจากทรัพยากร API ทั้งหมดมี URI ที่ไม่ซ้ำกันซึ่งเข้าถึง HTTP ได้ REST จะเปิดใช้การแคชข้อมูล และได้รับการเพิ่มประสิทธิภาพให้ทำงานกับโครงสร้างพื้นฐานแบบกระจายของเว็บ
ดูคำจำกัดความของเมธอดในเอกสารประกอบของมาตรฐาน HTTP 1.1 ซึ่งมีประโยชน์มาก มีข้อมูลจำเพาะสำหรับ GET
, POST
, PUT
และ DELETE
ส่วนที่เหลือใน AdMob API
การดำเนินการของ AdMob API จะจับคู่กับคำกริยา HTTP ของ REST โดยตรง
รูปแบบเฉพาะสำหรับ URI ของ AdMob API มีดังนี้
https://admob.googleapis.com/v1/resourcePath?parameters
ชุด URI แบบเต็มซึ่งใช้สำหรับการดำเนินการที่รองรับแต่ละรายการใน API จะสรุปไว้ในเอกสารเอกสารอ้างอิง AdMob API
ดูข้อมูลเบื้องต้นเกี่ยวกับ JSON
AdMob API จะแสดงข้อมูลในรูปแบบ JSON
JSON (JavaScript Object Notation) เป็นรูปแบบข้อมูลทั่วไปที่ไม่ขึ้นอยู่กับภาษา ซึ่งมีการนำเสนอแบบข้อความอย่างง่ายของโครงสร้างข้อมูลที่กำหนดเอง สำหรับข้อมูลเพิ่มเติม โปรดดู json.org
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-31 UTC
[null,null,["อัปเดตล่าสุด 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"]]