我在从 Google 的管理 API 站点找出这段代码的确切位置时遇到了麻烦。我让他们的 HelloAnalytics 程序正常工作:
# Note: This code assumes you have an authorized Analytics service object.
# See the User Permissions Developer Guide for details.
# Example #1:
# Requests a list of all account-user links for the authorized user.
try:
account_links = analytics.management().accountUserLinks().list(
accountId='123456'
).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:
# The results of the list method are stored in the account_links object.
# The following code shows how to iterate through them.
for accountUserLink in account_links.get('items', []):
entity = accountUserLink.get('entity', {})
accountRef = entity.get('accountRef', {})
userRef = accountUserLink.get('userRef', {})
permissions = accountUserLink.get('permissions', {})
print 'Account User Link Id = %s' % accountUserLink.get('id')
print 'Account User Link kind = %s' % accountUserLink.get('kind')
print 'User Email = %s' % userRef.get('email')
print 'Permissions effective = %s' % permissions.get('effective')
print 'Permissions local = %s' % permissions.get('local')
print 'Account Id = %s' % accountRef.get('id')
print 'Account Kind = %s' % accountRef.get('kind')
print 'Account Name = %s\n' % accountRef.get('name')
谁能帮帮我?我想要一个程序,我可以从中提取用户帐户电子邮件并查看/更新权限。我觉得这个程序除了帐户 ID 和 OAuth 链接之外,对于所有 Google Management API 用户来说都是类似的。