Requiere autorización
Muestra una lista de las propiedades a las que el usuario tiene acceso. Pruébalo ahora y ve un ejemplo.
Además de los parámetros estándar, este método admite los parámetros enumerados en la tabla de parámetros.
Solicitud
Solicitud HTTP
GET https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties
Parámetros
Nombre del parámetro | Valor | Descripción |
---|---|---|
Parámetros de ruta de acceso | ||
accountId |
string |
ID de la cuenta para las que se recuperarán las propiedades web. Puede ser un ID de cuenta específico o "~all ", que hace referencia a todas las cuentas a las que tiene acceso el usuario.
|
Parámetros de consulta opcionales | ||
max-results |
integer |
La cantidad máxima de propiedades web que se incluyen en esta respuesta. |
start-index |
integer |
Un índice de la primera entidad que se recuperará. Utiliza este parámetro como un mecanismo de paginación junto con el parámetro max-results .
|
Autorización
Esta solicitud requiere autorización con al menos uno de los siguientes alcances (obtén más información acerca de la autenticación y autorización).
Alcance |
---|
https://www.googleapis.com/auth/analytics |
https://www.googleapis.com/auth/analytics.edit |
https://www.googleapis.com/auth/analytics.readonly |
Cuerpo de la solicitud
No proporciones un cuerpo de la solicitud con este método.
Respuesta
La respuesta contiene un recurso de propiedad web por cada propiedad web de Analytics solicitada.
{ "kind": "analytics#webproperties", "username": string, "totalResults": integer, "startIndex": integer, "itemsPerPage": integer, "previousLink": string, "nextLink": string, "items": [ management.webproperties Resource ] }
Nombre de la propiedad | Valor | Descripción | Notas |
---|---|---|---|
kind |
string |
Tipo de colección. El valor es "analytics#webProperties ". |
|
username |
string |
ID de correo electrónico del usuario autenticado | |
totalResults |
integer |
El número total de resultados para la consulta, sin importar el número de resultados en la respuesta. | |
startIndex |
integer |
El índice inicial de los recursos, que es 1 de forma predeterminada o que se especifica en el parámetro de consulta start-index . |
|
itemsPerPage |
integer |
La cantidad máxima de recursos que puede contener la respuesta, sin importar la cantidad real de recursos que se muestran. Su valor varía entre 1 y 1,000, con un valor de 1,000 de forma predeterminada, o bien se especifica en el parámetro de consulta
max-results . |
|
previousLink |
string |
Vínculo a la página anterior de esta colección de propiedades web. | |
nextLink |
string |
Vínculo a la página siguiente de esta colección de propiedades web. | |
items[] |
list |
Una lista de propiedades web. |
Ejemplos
Nota: Los ejemplos de código disponibles para este método no representan todos los lenguajes de programación admitidos (consulta la página de bibliotecas cliente para consultar una lista de lenguajes admitidos).
Java
Usa la biblioteca cliente de 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
Utiliza la biblioteca cliente 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
Usa la biblioteca cliente de 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
Usa la biblioteca cliente de 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); } } }
Pruébalo
Usa el Explorador de APIs que aparece a continuación para llamar a este método con los datos en tiempo real y ver la respuesta. También puedes probar el Explorador independiente.