Ứng dụng đầu tiên của bạn: Đ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 có thể bắt đầu lập trình ứng dụng đầu tiên của mình, có một số việc bạn cần làm (nếu chưa thực hiện).
Tạo Tài khoản Google và nhận quyền truy cập vào Search Ads 360
Để sử dụng API Search Ads 360, bạn cần có một Tài khoản Google và các quyền thích hợp
được cấp cho tài khoản đó trong Search Ads 360:
Nếu bạn chưa có Tài khoản Google, hãy
tạo một tài khoản.
Yêu cầu Người quản lý đại lý trên Search Ads 360
tạo người dùng Search Ads 360 cho Tài khoản Google của bạn.
Để tải báo cáo xuống, bạn cần có quyền xem đối với những nhà quảng cáo mà bạn sẽ hợp tác.
Để thêm hoặc chỉnh sửa lượt chuyển đổi, bạn cần có quyền chỉnh sửa đối với những nhà quảng cáo mà bạn sẽ hợp tác. Trong cấu hình Floodlight dùng chung, bạn cần có quyền chỉnh sửa đối với từng nhà quảng cáo con mà bạn muốn tải lượt chuyển đổi lên.
Bạn không cần quyền truy cập vào nhà quảng cáo mẹ và bạn cũng không cần quyền truy cập vào các nhà quảng cáo con
mà bạn không tải lượt chuyển đổi lên. Nếu bạn sử dụng mã lượt nhấp để
phân bổ
lượt chuyển đổi cho lượt truy cập, hãy đảm bảo rằng bạn có quyền chỉnh sửa đối với nhà quảng cáo đã tạo ra
mã lượt nhấp đó. Nếu bạn chỉ định mã lượt nhấp qua một nhà quảng cáo mà bạn không có quyền chỉnh sửa, thì yêu cầu sẽ không thành công.
Người quản lý đại lý có thể thiết lập tài khoản của bạn làm Người dùng nhà quảng cáo có quyền truy cập vào một số nhà quảng cáo cụ thể hoặc thiết lập tài khoản của bạn có cấp truy cập cao hơn, chẳng hạn như Người dùng đại lý có quyền truy cập vào tất cả nhà quảng cáo trong đại lý.
Kích hoạt Dịch vụ chuyển đổi API
Nếu bạn muốn tải dữ liệu về lượt chuyển đổi lên, thì người dùng Search Ads 360 có đặc quyền Quản lý
đại lý cần phải đăng nhập vào giao diện người dùng Search Ads 360 và
kích hoạt dịch vụ chuyển đổi API. Hãy xem Trung tâm trợ giúp của Search Ads 360 để biết hướng dẫn.
Tạo dự án Bảng điều khiển API Google và thông tin xác thực OAuth cho ứng dụng
- Khởi động
công cụ thiết lập của Google API Console.
Công cụ thiết lập sẽ hướng dẫn bạn tạo dự án (hoặc sử dụng dự án hiện có), bật API Search Ads 360 và tạo thông tin xác thực OAuth 2.0.
- Trên trang Register your application (Đăng ký ứng dụng), hãy chọn một dự án hiện có hoặc chọn Create a project (Tạo dự án). Sau đó, hãy nhấp vào Tiếp tục.
- Sau khi Google API Console bật API Search Ads 360, hãy nhấp vào nút Chuyển đến thông tin xác thực.
- Trên trang Tạo thông tin xác thực, hãy nhập những thông tin sau:
-
Bạn đang sử dụng API nào?: API Search Ads 360
-
Bạn sẽ truy cập vào dữ liệu nào?: Dữ liệu người dùng
- Nhấp vào nút Tiếp theo.
Công cụ thiết lập hiện sẽ cung cấp khả năng giúp bạn tạo ID ứng dụng khách OAuth 2.0.
- Làm theo các bước còn lại trong công cụ thiết lập.
Cài đặt sa360Api.py
Search Ads 360 cung cấp một tập lệnh tiện ích để hỗ trợ quá trình thiết lập quyền uỷ quyền. Bạn cũng có thể sử dụng tập lệnh này để gửi và nhận dữ liệu ở định dạng JSON, nếu muốn thử gửi và nhận dữ liệu trước khi thiết kế và viết một ứng dụng đầy đủ. Bạn có thể sao chép nhiều ví dụ về JSON trong trang web tài liệu này và nhập trực tiếp các ví dụ đó vào tập lệnh.
Cách cài đặt tập lệnh:
- Cài đặt Python 2.7.
Tập lệnh không hoạt động với Python 3.x.
- Cài đặt cURL.
- Tải sa360Api.zip xuống.
- Trích xuất
sa360Api.py
từ sa360Api.zip
.
- Đặt
sa360Api.py
ở chế độ có thể thực thi.
Tìm hiểu kiến thức cơ bản về REST
Có hai cách để gọi API:
Nếu quyết định không sử dụng thư viện ứng dụng, bạn cần hiểu các 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 trong việc yêu cầu và sửa đổi dữ liệu.
Cụm từ REST là viết tắt của "Chuyển giao Trạng thái Trình bày". 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, 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á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 bản trình bày của tài nguyên đã 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 một tài nguyên theo URI duy nhất trên toàn hệ thống có dạng như 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; vì các định nghĩa này bao gồm thông số kỹ thuật cho GET
, POST
, PUT
và DELETE
.
REST trong API Search Ads 360
Các hoạt động API của Search Ads 360 có liên hệ trực tiếp đến các động từ HTTP. trong REST.
Định dạng cụ thể cho URI API Search Ads 360 là:
https://www.googleapis.com/doubleclicksearch/v2/resourcePath?parameters
Bạn có thể thấy tóm tắt về toàn bộ URI được sử dụng cho từng thao tác được hỗ trợ trong API trong Tài liệu tham khảo về API.
Tìm hiểu kiến thức cơ bản về JSON
Nếu sử dụng REST, bạn cần sử dụng định dạng JSON cho nội dung yêu cầu. Bạn có thể chỉ định rằng các phản hồi phải ở định dạng JSON hoặc CSV.
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: 2024-11-07 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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"]]