Hier werden alle Google Tag Manager-Konten aufgelistet, auf die ein Nutzer Zugriff hat. Probieren Sie es aus oder sehen Sie sich ein Beispiel an.
Anfragen
HTTP-Anfrage
GET https://www.googleapis.com/tagmanager/v1/accounts
Autorisierung
Diese Anfrage benötigt eine Autorisierung mit mindestens einem der folgenden Bereiche (weitere Informationen zu Authentifizierung und Autorisierung).
Umfang |
---|
https://www.googleapis.com/auth/tagmanager.readonly |
https://www.googleapis.com/auth/tagmanager.manage.accounts |
https://www.googleapis.com/auth/tagmanager.edit.containers |
Anfragetext
Mit dieser Methode keinen Anfragetext bereitstellen.
Antwort
Bei Erfolg gibt diese Methode einen Antworttext mit der folgenden Struktur zurück:
{ "accounts": [ accounts Resource ] }
Name der Eigenschaft | Wert | Beschreibung | Hinweise |
---|---|---|---|
accounts[] |
list |
Liste der Google Tag Manager-Konten, auf die ein Nutzer Zugriff hat. |
Beispiele
Hinweis: Bei den für diese Methode verfügbaren Codebeispielen sind nicht alle unterstützten Programmiersprachen vertreten. Eine Liste der unterstützten Sprachen finden Sie auf der Seite für Clientbibliotheken.
Java
Verwendet die Java-Clientbibliothek.
/* * Note: This code assumes you have an authorized tagmanager service object. */ /* * This request lists all accounts for the authorized user. */ try { ListAccountsResponse accounts = tagmanager.accounts().list().execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } /* * The results of the list method are stored in the accounts object. * The following code show how to iterate through them. */ for (Account account : accounts.getAccounts()) { System.out.println("Account Id = " + account.getAccountId()); System.out.println("Account Name = " + account.getName()); System.out.println("Account Share Data = " + account.getShareData()); System.out.println("Account Fingerprint = " + account.getFingerprint()); }
Python
Verwendet die Python-Clientbibliothek.
# Note: This code assumes you have an authorized tagmanager service object. # This request lists all accounts for the authorized user. try: accounts = tagmanager.accounts().list().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 dir(error) print ('There was an API error : %s : %s' % (error.resp.status, error.resp.reason)) # The results of the list method are stored in the accounts object. # The following code shows how to iterate through them. for account in accounts.get('accounts', []): print 'Account Id = %s' % account.get('accountId') print 'Account Name = %s' % account.get('name') print 'Account Share Data = %s' % account.get('shareData') print 'Account Fingerprint = %s' % account.get('fingerprint')
Jetzt testen
Verwenden Sie den unten angegebenen APIs Explorer, um diese Methode für Livedaten aufzurufen und die Antwort einzusehen.