Twoja pierwsza aplikacja: wymagania wstępne
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Zanim zaczniesz kodować swoją pierwszą aplikację kliencką, musisz wykonać kilka czynności.
Tworzenie konta Google i uzyskiwanie uprawnień Search Ads 360
Aby korzystać z interfejsu Search Ads 360 API, musisz mieć konto Google i odpowiednie uprawnienia przyznane temu kontu przez Search Ads 360:
Jeśli nie masz jeszcze konta Google,
utwórz je.
Poproś menedżera agencji Search Ads 360 o
utworzenie użytkownika Search Ads 360 na Twoim koncie Google.
Aby pobierać raporty, musisz mieć uprawnienia do wyświetlania danych reklamodawców, z którymi będziesz współpracować.
Aby dodawać lub edytować konwersje, musisz mieć uprawnienia do edytowania właściwości reklamodawców, z którymi będziesz współpracować. W przypadku udostępnionej konfiguracji Floodlight potrzebujesz uprawnień do edycji każdego reklamodawcy podrzędnego, do którego chcesz przesyłać konwersje.
Nie potrzebujesz dostępu do reklamodawcy nadrzędnego ani podrzędnego, do którego nie przesyłasz konwersji. Jeśli do przypisywania konwersji do wizyt używasz identyfikatorów kliknięć, upewnij się, że masz uprawnienia do edycji na koncie reklamodawcy, które wygenerowało dany identyfikator kliknięcia. Jeśli określisz identyfikator kliknięcia od reklamodawcy, do którego nie masz uprawnień dostępu, przesyłanie się nie powiedzie.
Menedżer agencji może skonfigurować Twoje konto jako Użytkownik na poziomie reklamodawcy z dostępem do konkretnych reklamodawców lub skonfigurować konto z wyższym poziomem dostępu, np. Użytkownik w agencji, z dostępem do wszystkich reklamodawców w agencji.
Aktywowanie usługi konwersji za pomocą interfejsu API
Jeśli chcesz przesyłać dane o konwersjach, użytkownik Search Ads 360 z uprawnieniami menedżera agencji musi zalogować się w interfejsie Search Ads 360 i aktywować usługę konwersji API. Instrukcje znajdziesz w Centrum pomocy Search Ads 360.
Utwórz projekt Konsoli interfejsów API Google i dane logowania OAuth dla klienta
- Uruchom
narzędzie do konfiguracji w Konsoli interfejsów API Google.
Narzędzie do konfiguracji przeprowadzi Cię przez proces tworzenia projektu (lub korzystania z istniejącego projektu), włączania interfejsu Search Ads 360 API i tworzenia danych logowania OAuth 2.0.
- Na stronie Zarejestruj aplikację wybierz istniejący projekt lub kliknij Utwórz projekt. Następnie kliknij Dalej.
- Gdy konsola interfejsów API Google włączy interfejs Search Ads 360 API, kliknij przycisk Przejdź do danych logowania.
- Na stronie Utwórz dane logowania podaj te informacje:
-
Którego interfejsu API używasz?: Interfejs API Search Ads 360
-
Do jakich danych będziesz mieć dostęp?: Dane użytkownika
- Kliknij przycisk Dalej.
Narzędzie konfiguracyjne pomaga teraz w tworzeniu identyfikatora klienta OAuth 2.0.
- Wykonaj pozostałe kroki opisane w narzędziu konfiguracji.
Zainstaluj plik sa360Api.py
Search Ads 360 udostępnia skrypt narzędziowy ułatwiający konfigurowanie autoryzacji. Możesz też użyć tego skryptu do wysyłania i odbierania danych w formacie JSON,
jeśli chcesz przetestować wysyłanie i odbieranie danych, zanim zaprojektujesz i napiszesz pełną aplikację. Możesz skopiować wiele przykładów kodu JSON z tej strony z dokumentacją i wstawić je bezpośrednio do skryptu.
Aby zainstalować skrypt:
- Zainstaluj Pythona 2.7.
Skrypt nie działa z Pythonem 3.x.
- Zainstaluj cURL.
- Pobierz plik sa360Api.zip.
- Wyodrębnij
sa360Api.py
z sa360Api.zip
.
- Utwórz plik wykonywalny
sa360Api.py
.
Podstawy protokołu REST
Interfejs API można wywołać na 2 sposoby:
Jeśli zdecydujesz się nie używać bibliotek klienta, musisz znać podstawy REST.
REST to styl architektury oprogramowania, który zapewnia wygodne i spójne podejście do wysyłania żądań i modyfikowania danych.
Termin REST to skrót od Representational State Transfer. W kontekście interfejsów API Google odnosi się to używania czasowników HTTP do pobierania i modyfikowania reprezentacji danych przechowywanych przez Google.
W systemie RESTful zasoby są przechowywane w magazynie danych. Klient wysyła żądanie, aby serwer wykonał określone działanie (np. utworzenie, pobranie, zaktualizowanie lub usunięcie zasobu), a serwer wykonuje to działanie i wysyła odpowiedź, często w formie reprezentacji określonego zasobu.
W interfejsach API REST Google klient określa działanie za pomocą czasownika HTTP, takiego jak POST
, GET
, PUT
lub DELETE
. Wskazuje zasób za pomocą globalnie unikalnego identyfikatora URI o następującej postaci:
https://www.googleapis.com/apiName/apiVersion/resourcePath?parameters
Wszystkie zasoby interfejsu API mają unikalne identyfikatory URI dostępne w ramach protokołu HTTP, a dzięki temu REST umożliwia buforowanie danych i jest zoptymalizowany pod kątem pracy z rozproszoną infrastrukturą sieci.
Definicje metod znajdziesz w dokumentacji standardów HTTP 1.1. Obejmują one specyfikacje GET
, POST
, PUT
i DELETE
.
Interfejs REST w Search Ads 360 API
Operacje interfejsu Search Ads 360 API są mapowane bezpośrednio na czasowniki HTTP REST.
Format URI interfejsu Search Ads 360 to:
https://www.googleapis.com/doubleclicksearch/v2/resourcePath?parameters
Pełny zestaw identyfikatorów URI używanych do każdej obsługiwanej operacji w interfejsie API jest podsumowany w przewodniku po interfejsie API.
Podstawy formatu JSON
Jeśli korzystasz z interfejsu REST, musisz używać formatu JSON w treści żądania. Możesz określić, że odpowiedzi będą w formacie JSON lub CSV.
JSON (JavaScript Object Notation) to popularny, niezależny od języka format danych, który w prosty sposób przedstawia dowolne struktury danych w formie tekstowej. Więcej informacji znajdziesz na stronie json.org.
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2024-11-07 UTC.
[null,null,["Ostatnia aktualizacja: 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"]]