需要授权
更新现有用户对给定数据视图(配置文件)的权限。立即试用或查看示例。
除了标准参数之外,此方法还支持参数表中列出的参数。
请求
HTTP 请求
PUT https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/profiles/profileId/entityUserLinks/linkId
参数
参数名称 | 值 | 说明 |
---|---|---|
路径参数 | ||
accountId |
string |
要为其更新用户关联的帐号 ID。 |
linkId |
string |
要为其更新用户关联的关联 ID。 |
profileId |
string |
要为其更新用户关联的数据视图(配置文件 ID)。 |
webPropertyId |
string |
要为其更新用户关联的网络媒体资源 ID。 |
授权
此请求需要获得下列范围的授权(详细了解身份验证和授权)。
范围 |
---|
https://www.googleapis.com/auth/analytics.manage.users |
请求正文
在请求正文中提供一个 management.entityUserLink 资源。
响应
如果成功,此方法将在响应正文中返回一个 management.entityUserLink 资源。
示例
注意:此方法的代码示例并未列出所有受支持的编程语言(请参阅客户端库页面,查看受支持的语言列表)。
Java
使用 Java 客户端库。
/* * Note: This code assumes you have an authorized Analytics service object. * See the User Permissions Developer Guide for details. */ /* * This request updates an existing Profile User Link. */ // Construct the permissions object. Permissions permissions = new Permissions(); List<String> local = Arrays.asList("EDIT"); permissions.setLocal(local); // Construct the body of the request. EntityUserLink body = new EntityUserLink(); body.setPermissions(permissions); try { analytics.management().profileUserLinks().update("123456", "UA-123456-1", "7654321", "7654321:1111222233334444", body).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 User Permissions Developer Guide for details. */ // Create the permissions object. $permissions = new Google_Service_Analytics_EntityUserLinkPermissions(); $permissions->setLocal(array('COLLABORATE', 'READ_AND_ANALYZE')); // Create the view (profile) link. $link = new Google_Service_Analytics_EntityUserLink(); $link->setPermissions($permissions); // This request updates an existing View (Profile) User Link. try { $analytics->management_profileUserLinks->update('123456', 'UA-123456-1', '756321', '756321:111222333444555', $link); } 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 User Permissions Developer Guide for details. # This request updates an existing Profile User Link. try: analytics.management().profileUserLinks().update( accountId='123456', webPropertyId='UA-123456-1', profileId='7654321', linkId='7654321:1111222233334444', body={ 'permissions': { 'local': [ 'EDIT' ] }, } ).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 User Permissions Developer Guide for details. */ /* * This request updates an existing View (Profile) User Link. */ function updateProfileUserLink() { var request = gapi.client.analytics.management.profileUserLinks.update( { 'accountId': '123456', 'webPropertyId': 'UA-123456-1', 'profileId': '7654321', 'linkId': '7654321:1111222233334444', 'resource': { 'permissions': { 'local': ['READ_AND_ANALYZE'] } } }); request.execute(function (response) { // Handle the response. }); }
试试看!
请使用下面的 API Explorer 对实际数据调用此方法,并查看响应。或者,您也可以尝试使用独立的 Explorer。