קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Google מספקת ספריית לקוח Python ליצירת אינטראקציה עם Ad Manager API.
מומלץ להשתמש בספריית הלקוח עם PyPI.
כדי להתחיל, יוצרים פרויקט חדש בסביבת הפיתוח המשולבת (IDE) שבחרתם או מוסיפים את התלות לפרויקט קיים. Google מפרסמת את הארטיפקטים של ספריות הלקוח ב-PyPI בתור google-ads-admanager.
פרטי הכניסה של משתמשים שהוגדרו דרך Google Cloud CLI (CLI של gcloud).
כשהאפליקציה פועלת ב-Google Cloud, חשבון השירות שמצורף למשאב ב-Google Cloud.
במאמר הבא מוסבר איך ליצור ולהגדיר את פרטי הכניסה ל-ADC.
אימות.
שליחת הבקשה הראשונה
לכל שירות יש אובייקט ServiceClient עם גם סינכרוני וגם אסינכרוני
לכל method של REST. בדוגמה הבאה כתוב Network
באופן סינכרוני.
fromgoogle.adsimportadmanager_v1defsample_get_network():# Create a clientclient=admanager_v1.NetworkServiceClient()# Initialize request argument(s)request=admanager_v1.GetNetworkRequest(name="networks/[NETWORK_CODE]",)# Make the requestresponse=client.get_network(request=request)# Handle the responseprint(response)
שגיאות ב-Ad Manager API כוללות גם את הערך הייחודי requestId, שאפשר לספק לתמיכה כדי לקבל עזרה בפתרון הבעיה. הדוגמה הבאה מחלצת את
requestId מ-GoogleAPIError;
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-02-27 (שעון UTC)."],[[["Google provides a Python client library, `google-ads-admanager`, for seamless interactions with the Ad Manager API, installable via pip."],["The client library utilizes Application Default Credentials (ADC) for authentication, prioritizing environment variables, gcloud CLI, and Google Cloud resource service accounts."],["Developers can make requests to various Ad Manager services using synchronous or asynchronous methods provided by service-specific client objects."],["Error handling is facilitated through the `GoogleAPIError` base class and its `reason` field, enabling developers to identify and manage issues effectively."],["Proxy settings can be configured using the `http_proxy` and `https_proxy` environment variables, allowing customization of network communication."]]],["The content outlines using Google's Python client library for the Ad Manager API. Key actions include installing the `google-ads-admanager` library via PyPI and configuring credentials using OAuth2 and Application Default Credentials (ADC), with environment variables, the Google Cloud CLI, or service accounts. A request is made to read a network, demonstrating synchronous method usage. Error handling is shown using `GoogleAPIError` to get `requestId` and using `e.reason`. It details configuring the proxy settings for the library via `http_proxy` and `https_proxy`.\n"]]