مطلوب تفويض
يسرد المواقع التي يمكن للمستخدم الدخول إليها. جرِّب ذلك الآن أو اطّلِع على مثال.
بالإضافة إلى المعلّمات العادية، تدعم هذه الطريقة المعلّمات المدرجة في جدول المعلّمات.
طلب
طلب HTTP
GET https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties
المَعلمات
اسم المعلَمة | القيمة | الوصف |
---|---|---|
معلّمات المسار | ||
accountId |
string |
معرّف الحساب لاسترداد مواقع الويب. يمكن أن يكون رقم تعريف حساب محدّدًا أو '؛~all '؛ والذي يشير إلى جميع الحسابات التي يمكن للمستخدم الوصول إليها.
|
معلَمات طلب البحث الاختيارية | ||
max-results |
integer |
الحد الأقصى لعدد مواقع الويب التي سيتم تضمينها في هذه الاستجابة. |
start-index |
integer |
فهرس للكيان الأول المطلوب استرداده. استخدِم هذه المعلّمة كآلية للتقسيم على صفحات إلى جانب المعلَمة max-results .
|
التفويض
ويتطلب هذا الطلب تفويضًا باستخدام نطاق واحد على الأقل من النطاقات التالية (مزيد من المعلومات عن المصادقة والتفويض).
النطاق |
---|
https://www.googleapis.com/auth/analytics |
https://www.googleapis.com/auth/analytics.edit |
https://www.googleapis.com/auth/analytics.readonly |
نص الطلب
لا توفِّر نص طلب بهذه الطريقة.
الإجابة
تحتوي الإجابة على مورد موقع إلكتروني واحد لكل موقع إلكتروني مطلوب في "إحصاءات Google".
{ "kind": "analytics#webproperties", "username": string, "totalResults": integer, "startIndex": integer, "itemsPerPage": integer, "previousLink": string, "nextLink": string, "items": [ management.webproperties Resource ] }
اسم الموقع | القيمة | الوصف | ملاحظات |
---|---|---|---|
kind |
string |
نوع المجموعة القيمة هي "analytics#webProperties ". |
|
username |
string |
رقم تعريف البريد الإلكتروني للمستخدم الذي تمت المصادقة عليه | |
totalResults |
integer |
إجمالي عدد نتائج طلب البحث، بغض النظر عن عدد النتائج في الاستجابة. | |
startIndex |
integer |
فهرس بداية الموارد، والذي يكون 1 تلقائيًا أو يتم تحديده بخلاف ذلك من خلال معلَمة طلب البحث start-index . |
|
itemsPerPage |
integer |
الحد الأقصى لعدد الموارد التي يمكن أن تحتوي عليها الاستجابة، بغض النظر عن العدد الفعلي للموارد المعروضة. وتتراوح قيمتها بين 1 و1000 مع القيمة 1000 تلقائيًا، أو كما هو محدّد من خلال معلَمة طلب البحث
max-results . |
|
previousLink |
string |
رابط إلى الصفحة السابقة لمجموعة مواقع الويب هذه. | |
nextLink |
string |
رابط إلى الصفحة التالية لمجموعة مواقع الويب هذه. | |
items[] |
list |
قائمة بمواقع الويب. |
أمثلة
ملاحظة: إنّ الأمثلة المرتبطة بالرموز والمتوفرة لهذه الطريقة لا تمثّل كل لغات البرمجة المتوافقة (يُرجى مراجعة صفحة مكتبات البرامج للاطّلاع على قائمة باللغات المتوافقة).
Java
يستخدم مكتبة برامج Java.
/** * Note: This code assumes you have an authorized Analytics service object. * See the Web Property Developer Guide for details. */ /** * Example #1: * Requests a list of all properties for the authorized user. */ try { Webproperties properties = analytics.management. webproperties.list("12345").execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } /** * Example #2: * Retrieves all properties for the user's account, using a * wildcard '~all' as the accountId. */ Webproperties properties = analytics.management. webproperties.list("~all").execute(); /** * Example #3: * The results of the list method are stored in the properties object. * The following code shows how to iterate through them. */ for (Webproperty property : properties.getItems()) { System.out.println("Account ID: " + property.getAccountId()); System.out.println("Property ID: " + property.getId()); System.out.println("Property Name: " + property.getName()); System.out.println("Property Profile Count: " + property.getProfileCount()); System.out.println("Property Industry Vertical: " + property.getIndustryVertical()); System.out.println("Property Internal Id: " + property.getInternalWebPropertyId()); System.out.println("Property Level: " + property.getLevel(); if (property.getWebsiteUrl() != null) { System.out.println("Property URL: " + property.getWebsiteUrl()); } System.out.println("Property Created: " + property.getCreated()); System.out.println("Property Updated: " + property.getUpdated()); }
PHP
استخدام مكتبة برامج PHP.
/** * Note: This code assumes you have an authorized Analytics service object. * See the Web Property Developer Guide for details. */ /** * Example #1: * Requests a list of all properties for the authorized user. */ try { $properties = $analytics->management_webproperties ->listManagementWebproperties('123456'); } 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(); } /** * Example #2: * Retrieves all properties for the user's account, using a * wildcard ~all as the accountId. */ $properties = $analytics->management_webproperties ->listManagementWebproperties('~all'); /** * Example #3: * The results of the list method are stored in the properties object. * The following code shows how to iterate through them. */ foreach ($properties->getItems() as $property) { $html = <<<HTML <pre> Account id = {$property->getAccountId()} Property id = {$property->getId()} Property name = {$property->getName()} Property URL = {$property->getWebsiteUrl()} Created = {$property->getCreated()} Updated = {$property->getUpdated()} </pre> HTML; print $html; }
Python
استخدام مكتبة برامج Python.
# Note: This code assumes you have an authorized Analytics service object. # See the Web Property Developer Guide for details. # Example #1: # Requests a list of all properties for the authorized user. try: properties = analytics.management().webproperties().list( accountId='12345').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)) # Example #2: # Retrieves all properties for the user's account, using a # wildcard ~all as the accountId. properties = service.management().webproperties().list( accountId='~all').execute() # Example #3: # The results of the list method are stored in the webproperties object. # The following code shows how to iterate through them. for property in properties.get('items', []): print 'Account ID = %s' % property.get('accountId') print 'Property ID = %s' % property.get('id') print 'Property Name = %s' % property.get('name') print 'Property Profile Count = %s' % property.get('profileCount') print 'Property Industry Vertical = %s' % property.get('industryVertical') print 'Property Internal Id = %s' % property.get( 'internalWebPropertyId') print 'Property Level = %s' % property.get('level') if property.get('websiteUrl'): print 'Property URL = %s' % property.get('websiteUrl') print 'Created = %s' % property.get('created') print 'Updated = %s' % property.get('updated')
JavaScript
استخدام مكتبة عميل JavaScript.
/* * Note: This code assumes you have an authorized Analytics client object. * See the Web Property Developer Guide for details. */ /* * Example 1: * Requests a list of all properties for the authorized user. */ function listProperties() { var request = gapi.client.analytics.management.webproperties.list({ 'accountId': '123456' }); request.execute(printProperties); } /* * Example 2: * The results of the list method are passed as the results object. * The following code shows how to iterate through them. */ function printProperties(results) { if (results && !results.error) { var properties = results.items; for (var i = 0, property; property = properties[i]; i++) { console.log('Account Id: ' + property.accountId); console.log('Property Id: ' + property.id); console.log('Property Name: ' + property.name); console.log('Property Profile Count: ' + property.profileCount); console.log('Property Industry Vertical: ' + property.industryVertical); console.log('Property Internal Id: ' + property.internalWebPropertyId); console.log('Property Level: ' + property.level); if (property.websiteUrl) { console.log('Property URL: ' + property.websiteUrl); } console.log('Created: ' + property.created); console.log('Updated: ' + property.updated); } } }
جرِّب هذه الميزة الآن.
استخدِم "مستكشف واجهات برمجة التطبيقات" أدناه لطلب هذه الطريقة في البيانات المباشرة والاطّلاع على الاستجابة. يمكنك بدلاً من ذلك تجربة المستكشف المستقل.