اولین برنامه شما: پیش نیازها
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
قبل از اینکه بتوانید اولین برنامه مشتری خود را کدنویسی کنید، اگر قبلاً آنها را انجام نداده اید، باید چند کار را انجام دهید.
یک حساب Google ایجاد کنید و مجوزهای Search Ads 360 را دریافت کنید
برای استفاده از Search Ads 360 API، به یک حساب Google و مجوزهای مناسب از Search Ads 360 به آن حساب اعطا شده است:
اگر قبلاً یک حساب Google ندارید، یک حساب ایجاد کنید .
از مدیر آژانس Search Ads 360 بخواهید که یک کاربر Search Ads 360 برای حساب Google شما ایجاد کند .
برای دانلود گزارشها، به مجوز مشاهده برای تبلیغکنندگانی که با آنها کار میکنید نیاز دارید.
برای افزودن یا ویرایش تبدیلها، به مجوز ویرایش برای تبلیغکنندگانی که با آنها کار میکنید نیاز دارید. در یک پیکربندی مشترک Floodlight ، برای هر تبلیغکننده فرزندی که میخواهید تبدیلها را در آن آپلود کنید، به مجوز ویرایش نیاز دارید. شما نیازی به دسترسی به تبلیغکننده والدین ندارید، و همچنین نیازی به دسترسی به تبلیغکنندگان فرزندی ندارید که تبدیلها را در آنها آپلود نمیکنید. اگر از شناسههای کلیک برای نسبت دادن تبدیل به بازدیدها استفاده میکنید، مطمئن شوید که به تبلیغکنندهای که شناسه کلیک را ایجاد کرده است، دسترسی ویرایش دارید. اگر شناسه کلیکی را از تبلیغکنندهای که دسترسی ویرایش به آن ندارید مشخص کنید، درخواست موفق نخواهد شد.
مدیر آژانس میتواند حساب شما را بهعنوان یک کاربر تبلیغکننده با دسترسی به تبلیغکنندگان خاص راهاندازی کند، یا حساب شما را با سطح دسترسی بالاتری مانند کاربر آژانس با دسترسی به همه تبلیغکنندگان در آژانس راهاندازی کند.
سرویس تبدیل API را فعال کنید
اگر میخواهید دادههای مربوط به تبدیلها را آپلود کنید، کاربر Search Ads 360 با امتیازات Agency Manager باید وارد رابط کاربری Search Ads 360 شود و سرویس تبدیل API را فعال کند . برای دستورالعمل ها به مرکز راهنمای Search Ads 360 مراجعه کنید.
یک پروژه Google API Console و اعتبارنامه OAuth برای مشتری خود ایجاد کنید
- ابزار تنظیم Google API Console را راه اندازی کنید.
ابزار راهاندازی شما را از طریق ایجاد یک پروژه (یا استفاده از یک پروژه موجود)، فعال کردن Search Ads 360 API و ایجاد اعتبارنامه OAuth 2.0 راهنمایی میکند. - در صفحه ثبت درخواست خود ، یک پروژه موجود را انتخاب کنید یا ایجاد پروژه را انتخاب کنید. سپس روی Continue کلیک کنید.
- پس از اینکه Google API Console API Search Ads 360 را فعال کرد، روی دکمه Go to credentials کلیک کنید.
- در صفحه Create credentials اطلاعات زیر را وارد کنید:
- از کدام API استفاده می کنید؟ : Search Ads 360 API
- به چه داده هایی دسترسی خواهید داشت؟ : داده های کاربر
- روی دکمه Next کلیک کنید.
ابزار راهاندازی اکنون به شما کمک میکند تا یک شناسه مشتری OAuth 2.0 ایجاد کنید.
- بقیه مراحل را در ابزار راه اندازی دنبال کنید.
sa360Api.py را نصب کنید
Search Ads 360 یک اسکریپت کاربردی برای تسهیل فرآیند تنظیم مجوز ارائه می دهد. همچنین می توانید از این اسکریپت برای ارسال و دریافت داده ها در قالب JSON استفاده کنید، اگر می خواهید قبل از طراحی و نوشتن یک برنامه کامل، ارسال و دریافت داده را امتحان کنید. میتوانید بسیاری از نمونههای JSON را در این سایت مستندسازی کپی کرده و مستقیماً در اسکریپت وارد کنید.
برای نصب اسکریپت:
- پایتون 2.7 را نصب کنید .
اسکریپت با Python 3.x کار نمی کند. - cURL را نصب کنید .
- sa360Api.zip را دانلود کنید .
-
sa360Api.py
از sa360Api.zip
استخراج کنید. -
sa360Api.py
قابل اجرا کنید.
اصول REST را بیاموزید
دو راه برای فراخوانی API وجود دارد:
اگر تصمیم دارید از کتابخانه های مشتری استفاده نکنید، باید اصول REST را بدانید.
REST سبکی از معماری نرم افزار است که یک رویکرد راحت و سازگار برای درخواست و اصلاح داده ها ارائه می دهد.
اصطلاح REST مخفف " انتقال دولت نمایندگی " است. در زمینه Google API ها، به استفاده از افعال HTTP برای بازیابی و اصلاح نمایش داده های ذخیره شده توسط Google اشاره دارد.
در یک سیستم RESTful، منابع در یک فروشگاه داده ذخیره می شوند. یک سرویس گیرنده درخواستی را ارسال می کند که سرور یک عمل خاص را انجام دهد (مانند ایجاد، بازیابی، به روز رسانی یا حذف یک منبع)، و سرور این عمل را انجام می دهد و پاسخی را می فرستد، اغلب به شکل یک نمایش از منبع مشخص شده.
در API های RESTful 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
هستند.
در Search Ads 360 API استراحت کنید
عملیات Search Ads 360 API مستقیماً به افعال HTTP REST نگاشت.
فرمت خاص برای URI های API Search Ads 360 این است:
https://www.googleapis.com/doubleclicksearch/v2/resourcePath?parameters
مجموعه کامل URI های مورد استفاده برای هر عملیات پشتیبانی شده در API در مرجع API خلاصه شده است.
اصول JSON را بیاموزید
اگر از REST استفاده می کنید، باید از فرمت JSON برای بدنه های درخواست استفاده کنید. می توانید مشخص کنید که پاسخ ها در قالب JSON یا CSV باشند.
JSON (JavaScript Object Notation) یک قالب داده رایج و مستقل از زبان است که نمایش متنی ساده ای از ساختارهای داده دلخواه را ارائه می دهد. برای اطلاعات بیشتر، به json.org مراجعه کنید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2024-11-14 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-11-14 بهوقت ساعت هماهنگ جهانی."],[[["\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"]]