مطلوب تفويض
تعديل رابط webProperty-إعلانات Google الحالي. جرِّب ذلك الآن أو اطّلِع على مثال.
طلب
طلب HTTP
PUT https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/entityAdWordsLinks/webPropertyAdWordsLinkId
المَعلمات
اسم المعلَمة | القيمة | الوصف |
---|---|---|
معلّمات المسار | ||
accountId |
string |
رقم تعريف الحساب الذي ينتمي إليه الموقع الإلكتروني المحدد. |
webPropertyAdWordsLinkId |
string |
رقم تعريف رابط "إعلانات Google" على الويب. |
webPropertyId |
string |
معرّف الموقع الإلكتروني لاسترداد رابط "إعلانات Google". |
التفويض
ويتطلب هذا الطلب الحصول على تفويض من النطاق التالي (مزيد من المعلومات حول المصادقة والتفويض).
النطاق |
---|
https://www.googleapis.com/auth/analytics.edit |
نص الطلب
في نص الطلب، قدِّم مورد روابط "إعلانات Google" مع السمات التالية:
اسم الموقع | القيمة | الوصف | ملاحظات |
---|---|---|---|
السمات المطلوبة | |||
adWordsAccounts[] |
list |
قائمة بحسابات عملاء "إعلانات Google". ويجب ألا تكون هذه الحسابات حسابات "مركز عملائي". هذا الحقل مطلوب عند إنشاء رابط "إعلانات Google". يجب عدم ترك الحقل فارغًا. | قابل للكتابة |
adWordsAccounts[].customerId |
string |
الرقم التعريفي للعميل. هذا الحقل مطلوب عند إنشاء رابط "إعلانات Google". | |
name |
string |
اسم الرابط هذا الحقل مطلوب عند إنشاء رابط "إعلانات Google". | قابل للكتابة |
الإجابة
وإذا نجحت، ستعرض هذه الطريقة مورد روابط "إعلانات Google" في نص الاستجابة.
أمثلة
ملاحظة: إنّ الأمثلة المرتبطة بالرموز والمتوفرة لهذه الطريقة لا تمثّل كل لغات البرمجة المتوافقة (يُرجى مراجعة صفحة مكتبات البرامج للاطّلاع على قائمة باللغات المتوافقة).
Java
يستخدم مكتبة برامج Java.
/* * Note: this code assumes you have an authorized Analytics service object. * See the Google Ads Links Developer Guide for details. */ /* * This request updates an existing Google Ads Link. */ // Construct a list of AdWordsAccounts. AdWordsAccount adWordsAccount = new AdWordsAccount(); adWordsAccount.setCustomerId("123-456-7890"); List<AdWordsAccount> adWordsAccounts = Arrays.asList(adWordsAccount); // Construct the body of the request. EntityAdWordsLink adWordsLink = new EntityAdWordsLink(); adWordsLink.setAdWordsAccounts(adWordsAccounts); adWordsLink.setName("Google Ads Link"); try{ analytics.management().webPropertyAdWordsLinks().update("123456", "UA-123456-1", "AABBCCDDEEFFGG", adWordsLink).execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); }
PHP
استخدام مكتبة برامج PHP.
/** * Note: This code assumes you have an authorized Analytics service object. * See the Google Ads Links Developer Guide for details. */ /** * This request updates an existing Google Ads Link. */ // Construct an Google Ads account object. $adWordsAccount = new Google_Service_Analytics_AdWordsAccount(); $adWordsAccount->setCustomerId("123-456-7890"); // Construct the body of the request. $adWordsLink = new Google_Service_Analytics_EntityAdWordsLink(); $adWordsLink->setName('Google Ads Link'); $adWordsLink->setAdWordsAccounts(array($adWordsAccount)); try { $analytics->management_webPropertyAdWordsLinks->update('123456', 'UA-123456-1', 'AABBCCDDEEFFGG', $adWordsLink); } catch (apiServiceException $e) { print 'There was an Analytics API service error ' . $e->getCode() . ':' . $e->getMessage(); } catch (apiException $e) { print 'There was a general API error ' . $e->getCode() . ':' . $e->getMessage(); }
Python
استخدام مكتبة برامج Python.
# Note: This code assumes you have an authorized Analytics service object. # See the Google Ads Links Developer Guide for details. # This request updates an existing Google Ads Link. try: analytics.management().webPropertyAdWordsLinks().update( accountId='123456', webPropertyId='UA-123456-1', webPropertyAdWordsLinkId='AABBCCDDEEFFGG', body={ 'adWordsAccounts': [ { 'customerId': '123-456-7890' } ], 'name': 'Google Ads Link' } ).execute() except TypeError, error: # Handle errors in constructing a query. print 'There was an error in constructing your query : %s' % error except HttpError, error: # Handle API errors. print ('There was an API error : %s : %s' % (error.resp.status, error.resp.reason))
JavaScript
استخدام مكتبة عميل JavaScript.
/* * Note: This code assumes you have an authorized Analytics client object. * See the Google Ads Links Developer Guide for details. */ /* * This request updates an existing Google Ads Link. */ function updateAdWordsLink() { var request = gapi.client.analytics.management.webPropertyAdWordsLinks.update( { 'accountId': '123456', 'webPropertyId': 'UA-123456-1', 'webPropertyAdWordsLinks': '11112222233334444', 'resource': { 'adWordsAccounts': [ { 'customerId': '123-456-7890'} ], 'name': 'Updated Google Ads Link' } }); request.execute(function (response) { // Handle the response. }); }
جرِّب هذه الميزة الآن.
استخدِم "مستكشف واجهات برمجة التطبيقات" أدناه لطلب هذه الطريقة في البيانات المباشرة والاطّلاع على الاستجابة. يمكنك بدلاً من ذلك تجربة المستكشف المستقل.