แอปแรกของคุณ: ข้อกำหนดเบื้องต้น
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ก่อนที่คุณจะเริ่มเขียนโค้ดแอปพลิเคชันไคลเอ็นต์แรกได้ คุณต้องดำเนินการบางอย่างหากยังไม่ได้ทำ
สร้างบัญชี Google และรับสิทธิ์ใช้ Search Ads 360
หากต้องการใช้ Search Ads 360 API คุณต้องมีบัญชี Google และสิทธิ์ที่เหมาะสมซึ่งมอบให้แก่บัญชีดังกล่าวจาก Search Ads 360
หากคุณยังไม่มีบัญชี Google โปรด
สร้างขึ้น
ขอให้ผู้จัดการเอเจนซีของ Search Ads 360
สร้างผู้ใช้ Search Ads 360 สําหรับบัญชี Google ของคุณ
หากต้องการดาวน์โหลดรายงาน คุณต้องมีสิทธิ์ดูสำหรับผู้ลงโฆษณาที่คุณจะทํางานด้วย
หากต้องการเพิ่มหรือแก้ไข Conversion คุณจะต้องมีสิทธิ์แก้ไขสําหรับผู้ลงโฆษณาที่คุณจะทํางานด้วย ในการกําหนดค่า Floodlight ที่แชร์ คุณต้องมีสิทธิ์แก้ไขสําหรับผู้ลงโฆษณาย่อยแต่ละรายที่คุณต้องการอัปโหลด Conversion เข้าไป
คุณไม่จำเป็นต้องมีสิทธิ์เข้าถึงผู้ลงโฆษณาหลัก และไม่จำเป็นต้องเข้าถึงผู้ลงโฆษณาย่อยที่ไม่ได้อัปโหลด Conversion เข้าไป หากใช้รหัสคลิกเพื่อระบุแหล่งที่มาของ Conversion เป็นการเข้าชม ให้ตรวจสอบว่าคุณมีสิทธิ์แก้ไขของผู้ลงโฆษณาที่สร้างรหัสคลิกนั้นขึ้นมา หากคุณระบุรหัสคลิกจากผู้ลงโฆษณาที่คุณไม่มีสิทธิ์แก้ไข คำขอจะไม่สำเร็จ
ผู้จัดการเอเจนซีสร้างบัญชีของคุณเป็นผู้ใช้จากผู้ลงโฆษณาที่มีสิทธิ์เข้าถึงผู้ลงโฆษณาบางราย หรือตั้งค่าบัญชีด้วยระดับการเข้าถึงที่สูงขึ้น เช่น ผู้ใช้จากเอเจนซีโดยให้มีสิทธิ์เข้าถึงผู้ลงโฆษณาทั้งหมดในเอเจนซี
เปิดใช้งานบริการ Conversion API
หากต้องการอัปโหลดข้อมูลเกี่ยวกับ Conversion ผู้ใช้ Search Ads 360 ที่มีสิทธิ์ผู้จัดการเอเจนซีต้องลงชื่อเข้าใช้ UI ของ Search Ads 360 และเปิดใช้งานบริการ Conversion API ดูวิธีการที่ศูนย์ช่วยเหลือของ Search Ads 360
สร้างโปรเจ็กต์คอนโซล Google API และข้อมูลเข้าสู่ระบบ OAuth สำหรับลูกค้า
- เริ่ม
เครื่องมือการตั้งค่าคอนโซล Google API
เครื่องมือการตั้งค่าจะแนะนำขั้นตอนการสร้างโปรเจ็กต์ (หรือใช้โปรเจ็กต์ที่มีอยู่) การเปิดใช้ Search Ads 360 API และสร้างข้อมูลเข้าสู่ระบบ OAuth 2.0
- ในหน้าลงทะเบียนแอปพลิเคชัน ให้เลือกโปรเจ็กต์ที่มีอยู่หรือเลือกสร้างโปรเจ็กต์ แล้วคลิกดำเนินการต่อ
- หลังจากคอนโซล Google API เปิดใช้ Search Ads 360 API แล้ว ให้คลิกปุ่มไปที่ข้อมูลเข้าสู่ระบบ
- ในหน้าสร้างข้อมูลเข้าสู่ระบบ ให้ป้อนข้อมูลต่อไปนี้
-
คุณกำลังใช้ API ใด: Search Ads 360 API
-
คุณต้องการเข้าถึงข้อมูลใด ข้อมูลผู้ใช้
- คลิกปุ่มถัดไป
ในตอนนี้ เครื่องมือตั้งค่าจะเสนอเพื่อช่วยคุณสร้างรหัสไคลเอ็นต์ OAuth 2.0
- ทำตามขั้นตอนที่เหลือในเครื่องมือตั้งค่า
ติดตั้ง sa360Api.py
Search Ads 360 มีสคริปต์ยูทิลิตีเพื่ออำนวยความสะดวกในขั้นตอนการตั้งค่าการให้สิทธิ์ คุณยังใช้สคริปต์นี้เพื่อส่งและรับข้อมูลในรูปแบบ JSON หากต้องการลองส่งและรับข้อมูลก่อนออกแบบและเขียนแอปพลิเคชันแบบเต็ม คุณสามารถคัดลอกตัวอย่าง JSON จำนวนมากในเว็บไซต์เอกสารประกอบนี้และป้อนลงในสคริปต์ได้โดยตรง
วิธีติดตั้งสคริปต์
- ติดตั้ง Python 2.7
สคริปต์นี้ใช้กับ Python 3.x ไม่ได้
- ติดตั้ง cURL
- ดาวน์โหลด sa360Api.zip
- ดึงข้อมูล
sa360Api.py
จาก sa360Api.zip
- ทำให้
sa360Api.py
เป็นไฟล์ปฏิบัติการ
ดูข้อมูลเบื้องต้นเกี่ยวกับ REST
การเรียก API ทำได้ 2 วิธีดังนี้
หากตัดสินใจว่าจะไม่ใช้ไลบรารีไคลเอ็นต์ คุณจะต้องเข้าใจพื้นฐานของ REST
REST เป็นรูปแบบสถาปัตยกรรมซอฟต์แวร์ที่ให้แนวทางที่สะดวกและสอดคล้องกันในการขอและแก้ไขข้อมูล
คำว่า REST เป็นคำสั้นๆ ของ "Sentational State Transfer" ในบริบทของ Google API หมายถึงการใช้คํากริยา 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
REST ใน Search Ads 360 API
การดำเนินการของ Search Ads 360 API จะจับคู่กับคำกริยา HTTP ของ REST โดยตรง
รูปแบบที่เฉพาะเจาะจงสําหรับ URI ของ Search Ads 360 API มีดังนี้
https://www.googleapis.com/doubleclicksearch/v2/resourcePath?parameters
ชุด URI แบบเต็มที่ใช้สำหรับการดำเนินการที่รองรับแต่ละรายการใน API จะสรุปไว้ในเอกสารอ้างอิง API
ดูข้อมูลเบื้องต้นเกี่ยวกับ JSON
หากใช้ REST คุณจะต้องใช้รูปแบบ JSON สําหรับเนื้อหาคำขอ คุณสามารถระบุให้คำตอบอยู่ในรูปแบบ JSON หรือ CSV
JSON (JavaScript Object Notation) เป็นรูปแบบข้อมูลทั่วไปที่ไม่ขึ้นอยู่กับภาษา ซึ่งมีการนำเสนอแบบข้อความอย่างง่ายของโครงสร้างข้อมูลที่กำหนดเอง สำหรับข้อมูลเพิ่มเติม โปรดดู json.org
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-11-07 UTC
[null,null,["อัปเดตล่าสุด 2024-11-07 UTC"],[[["\u003cp\u003eBefore using the Search Ads 360 API, ensure you have a Google Account with the necessary Search Ads 360 permissions, which may include view or edit access to specific advertisers.\u003c/p\u003e\n"],["\u003cp\u003eTo upload conversion data, the API Conversion Service must be activated by a Search Ads 360 user with Agency Manager privileges.\u003c/p\u003e\n"],["\u003cp\u003eSet up a Google API Console project and obtain OAuth credentials for your client application to authenticate and authorize API access.\u003c/p\u003e\n"],["\u003cp\u003eInstall the provided \u003ccode\u003esa360Api.py\u003c/code\u003e utility script and familiarize yourself with REST and JSON basics if you plan to interact with the API directly without client libraries.\u003c/p\u003e\n"]]],["To start coding, create a Google Account and request Search Ads 360 permissions from an Agency Manager, who will grant view or edit access to advertisers. Activate the API conversion service via the Search Ads 360 UI. Next, create a Google API Console project and OAuth 2.0 credentials. Install Python 2.7, cURL, and the `sa360Api.py` utility script. Finally, understand REST basics and JSON formatting, crucial for interacting with the API using HTTP requests.\n"],null,["# Your First App: Prerequisites\n\nBefore you can start coding your first client application, there are a few things you\nneed to do, if you haven't done them already.\n\nCreate a Google Account and get Search Ads 360 permissions\n----------------------------------------------------------\n\nTo use the Search Ads 360 API, you need a Google Account and appropriate permissions\ngranted to that account from Search Ads 360:\n\n1. If you don't already have a Google Account, [create one](https://support.google.com/accounts/answer/27441).\n\n2. Ask a Search Ads 360 **Agency Manager** to [create a Search Ads 360 user](https://support.google.com/searchads/answer/6051717) for your Google Account.\n\n To download reports, you'll need **view permission** for the advertisers\n you'll be working with.\n\n To add or edit conversions, you'll need **edit permission** for the advertisers\n you'll be working with. In a\n [shared Floodlight configuration](https://support.google.com/searchads/answer/2458167),\n you need edit permission for each child advertiser you want to upload conversions into.\n You don't need access to the parent advertiser, nor do you need access to child advertisers\n that you're not uploading conversions into. If you use click IDs to\n [attribute\n conversions to visits](/search-ads/v2/how-tos/conversions/insert#attribute-a-conversion-to-a-specific-visit), make sure you have edit access to the advertiser that generated\n the click ID. If you specify a click ID from an advertiser you don't have edit access to,\n the request will not succeed.\n\n The Agency Manager can set up your account as an **Advertiser user** with\n access to specific advertisers,\n or set up your account with a higher level of access such as **Agency user**\n with access to all advertisers in the agency.\n\nActivate the API Conversion Service\n-----------------------------------\n\n\nIf you want to upload data about conversions, a Search Ads 360 user with **Agency\nManager** privileges needs to sign in to the Search Ads 360 UI and\n**activate the API conversion service** . See the\n[Search Ads 360\nhelp center](https://support.google.com/searchads/answer/2604604#activate) for instructions.\n\nCreate a Google API Console project and OAuth credentials for your client\n-------------------------------------------------------------------------\n\n1. Start the Google API Console [setup tool](https://console.cloud.google.com/start/api?id=doubleclicksearch&credential=client_key). \n The setup tool guides you through creating a project (or using an existing project), enabling the Search Ads 360 API, and creating OAuth 2.0 credentials.\n2. On the **Register your application** page, select an existing project or select **Create a project** . Then click **Continue**.\n3. After the Google API Console enables the Search Ads 360 API, click the **Go to credentials** button.\n4. On the **Create credentials** page, enter the following information:\n - **Which API are you using?**: Search Ads 360 API\n - **What data will you be accessing?**: User data\n5. Click the **Next** button.\n\n The setup tool now offers to help you create an **OAuth 2.0 client ID**.\n6. Follow the rest of the steps in the setup tool.\n\nInstall sa360Api.py\n-------------------\n\nSearch Ads 360 provides a utility script to facilitate the process of setting up\nauthorization. You can also use this script to send and receive data in the JSON format,\nif you want to try sending and receiving data before you design and write a full\napplication. You can copy many of the JSON examples in this documentation site and input\nthem directly to the script.\n\nTo install the script:\n\n1. [Install Python](http://www.python.org/getit/) 2.7. \n The script does not work with Python 3.x.\n2. [Install cURL](http://curl.haxx.se/download.html).\n3. [Download sa360Api.zip](https://www.google.com/help/hc/downloads/sa360/sa360Api.zip).\n4. Extract `sa360Api.py` from `sa360Api.zip`.\n5. Make `sa360Api.py` executable.\n\nLearn REST basics\n-----------------\n\nThere are two ways to invoke the API:\n\n- Using [client libraries](/search-ads/v2/libraries).\n- Sending HTTP requests and parsing the responses.\n\nIf you decide not to use client libraries, you'll need to understand the basics of\nREST.\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 Search Ads 360 API\n\nThe Search Ads 360 API operations map directly to REST HTTP verbs.\n\nThe specific format for Search Ads 360 API URIs is: \n\n```\nhttps://www.googleapis.com/doubleclicksearch/v2/resourcePath?parameters\n```\n\n\nThe full set of URIs used for each supported operation in the API is summarized in the [API Reference](/search-ads/v2/reference).\n\nLearn JSON basics\n-----------------\n\nIf you use REST, you'll need to use the JSON format for the request bodies. You can\nspecify that the responses be either in the JSON or CSV 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"]]