Google Ads 关联:get

需要授权

返回用户有权访问的网络媒体资源与 Google Ads 间关联。 立即试用查看示例

请求

HTTP 请求

GET https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/entityAdWordsLinks/webPropertyAdWordsLinkId

参数

参数名称 说明
路径参数
accountId string 给定网络媒体资源所属帐号的 ID。
webPropertyAdWordsLinkId string 网络媒体资源与 Google Ads 间关联的 ID。
webPropertyId string 网络媒体资源 ID,表示要获取哪项网络媒体资源的 Google Ads 关联。

授权

此请求至少需要获得以下任一范围的授权(详细了解身份验证和授权)。

范围
https://www.googleapis.com/auth/analytics.edit
https://www.googleapis.com/auth/analytics.readonly

请求正文

请勿使用此方法提供请求正文。

响应

如果成功,此方法将在响应正文中返回“Google Ads 关联”资源

示例

备注:为此方法提供的代码示例并未体现所有受支持的编程语言(请参阅“客户端库”页面,查看受支持语言的列表)。

Java

使用 Java 客户端库

/*
 * Note: this code assumes you have an authorized Analytics service object.
 * See the Google Ads Links Developer Guide for details.
 */

/*
 * This request gets an existing Google Ads Link.
 */
try{
  EntityAdWordsLink adWordsLink = analytics.management().
      webPropertyAdWordsLinks().get("123456",
          "UA-123456-1", "AABBCCDDEEFFGG").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 Google Ads Links Developer Guide for details.
 */

/**
 * This request gets an existing Google Ads Link.
 */

try {
  $adWordsLink = $analytics->management_webPropertyAdWordsLinks->get(
      '123456', 'UA-123456-1', 'AABBCCDDEEFFGG');

} 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 Google Ads Links Developer Guide for details.

# This request gets an existing Google Ads Link.
try:
  adWordsLink = analytics.management().webPropertyAdWordsLinks().get(
      accountId='123456',
      webPropertyId='UA-123456-1',
      webPropertyAdWordsLinkId='AABBCCDDEEFFGG'
  ).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 Google Ads Links Developer Guide for details.
 */

/*
 * This request gets an existing Google Ads Link.
 */
function getAdWordsLink() {
  var request = gapi.client.analytics.management.webPropertyAdWordsLinks.get({
    'accountId': '123456',
    'webPropertyId': 'UA-123456-1',
    'webPropertyAdWordsLinkId': '11112222233334444'
  });
  request.execute(function (response) { // Handle the response. });
}

立即试用!

请使用下面的 API Explorer 针对实时数据调用此方法并查看响应。或者,您还可以尝试使用独立版 Explorer