> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 获取广告活动

> 读取 Google Ads 活动的状态和每日预算，以及 Google 对其每个广告或素材资源的审核结果。

获取您通过 Ayrshare 创建的 Google Ads 活动：其名称、状态、每日预算，以及 Google 对其每个广告的审核结果。

## 请求头参数

**Authorization** `string` *required*

[API Key](https://www.ayrshare.com/docs/apis/overview.md#authorization) of the Primary Profile.

Format: `Authorization: Bearer API_KEY`
**Profile-Key** `string`

[Profile Key](https://www.ayrshare.com/docs/apis/overview.md#profile-key-format) of a User Profile.

Format: `Profile-Key: PROFILE_KEY`

## 路径参数

**id** `string` *required*

创建活动时返回的 `campaignId`。

## 响应

| 字段 | 内容 |
| - | - |
| `campaignId` | 活动的 ID |
| `name` | 活动名称 |
| `campaignStatus` | `active` 或 `paused` |
| `platformStatus` | Google 自身的状态：`ENABLED`、`PAUSED`，或对于在 Google Ads 中已删除的活动为 `REMOVED`。已移除的活动会保留您通过 Ayrshare 最后设置的 `campaignStatus` |
| `budget` | 每日预算：`amount`、`currency`（广告账户的币种）和 `type`（`daily`） |
| `ads` | Google 对每个广告（搜索）或素材资源（Performance Max）的审核结果。请参阅[广告审核](#ad-review) |

## 广告审核

Google 会根据其广告政策审核每个新广告，通常在一个工作日内完成。`ads` 中的每一行包含：

| 字段 | 内容 |
| - | - |
| `adId` | 广告的 ID，即创建时返回的 ID |
| `approvalStatus` | Google 的决定：`APPROVED`、`APPROVED_LIMITED`（受限展示，例如在某些国家/地区不展示）、`AREA_OF_INTEREST_ONLY` 或 `DISAPPROVED`。在 Google 作出决定之前，它会是其他值，例如 `UNKNOWN` 或 `UNSPECIFIED` |
| `reviewStatus` | 审核所处的阶段，例如 `REVIEW_IN_PROGRESS` 或 `REVIEWED` |
| `policyTopics` | 导致受限或拒登的政策：`[{ "topic": "ALCOHOL", "type": "PROHIBITED" }]` |

被拒登的广告不会投放。请在 Google Ads 中修改该广告，或使用合规的文字创建新活动。如果当时无法读取 Google 的审核结果，或读取耗时超过几秒钟，则会省略 `ads`；请稍后再次读取该活动。

Ayrshare 还会每晚检查每个审核结果，并在 Google 的决定发生变化时发送 `type: "reviewChanged"` 的 `ads` webhook。请参阅 [Ads Action](https://www.ayrshare.com/docs/apis/webhooks/actions.md#ads-action)。

## 素材资源审核

Google 会单独审核 Performance Max 活动的每个素材资源。`ads` 中每个素材资源占一行，字段与[广告审核](#ad-review)相同，另外还包括：

| 字段 | 内容 |
| - | - |
| `adId` | 该素材资源在此活动中的键：`asset:<assetGroupId>~<assetId>~<fieldType>`，品牌素材资源则为 `asset:<campaignId>~<assetId>~<fieldType>` |
| `assetId` | Google 为该素材资源分配的 ID |
| `fieldType` | 其使用位置，例如 `HEADLINE`、`MARKETING_IMAGE`、`SQUARE_MARKETING_IMAGE`、`BUSINESS_NAME` 或 `LOGO` |
| `primaryStatus` | 是否可以投放，例如 `ELIGIBLE` 或 `NOT_ELIGIBLE` |

商家名称、徽标和横向徽标属于品牌素材资源，关联到活动而不是素材资源组。它们在这里也有对应的行，排在素材资源组的行之后，以活动 ID 为键：`asset:<campaignId>~<assetId>~<fieldType>`，其中 `fieldType` 为 `BUSINESS_NAME`、`LOGO` 或 `LANDSCAPE_LOGO`。

## 错误

| 错误码 | 触发情况 |
| - | - |
| `400` | 该活动不属于您、不存在，或已不在该 Google Ads 账户中。您关联的 Google 用户无法访问该广告账户，或 Google Ads 访问权限已被撤销时，也会返回此错误。 |
| `370` | Google 无法完成该请求。请重试。 |

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-X GET "https://api.ayrshare.com/api/ads/google/campaigns/21534567890"
```

```javascript JavaScript theme={"system"}
const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${API_KEY}`
  }
})
  .then((res) => res.json())
  .then((json) => console.log(json))
  .catch(console.error);
```

```python Python theme={"system"}
import requests

headers = {
    "Authorization": "Bearer API_KEY",
}

r = requests.get("https://api.ayrshare.com/api/ads/google/campaigns/21534567890", headers=headers)

print(r.json())
```

```php PHP theme={"system"}
<?php
$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/campaigns/21534567890",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer API_KEY"
    ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error: " . $err;
} else {
    echo $response;
}
?>
```

```csharp C# theme={"system"}
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");

        var response = await client.GetAsync("https://api.ayrshare.com/api/ads/google/campaigns/21534567890");
        var content = await response.Content.ReadAsStringAsync();

        Console.WriteLine(content);
    }
}
```

```go Go theme={"system"}
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.ayrshare.com/api/ads/google/campaigns/21534567890", nil)
    req.Header.Add("Authorization", "Bearer API_KEY")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```java Java theme={"system"}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class GetCampaign {
    public static void main(String[] args) throws Exception {
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.ayrshare.com/api/ads/google/campaigns/21534567890"))
            .header("Authorization", "Bearer API_KEY")
            .GET()
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
```

```ruby Ruby theme={"system"}
require 'net/http'
require 'uri'

uri = URI.parse('https://api.ayrshare.com/api/ads/google/campaigns/21534567890')

request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer API_KEY'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

puts response.body
```

```json 200: Search Campaign theme={"system"}
{
  "status": "success",
  "platform": "google",
  "campaignId": "21534567890",
  "name": "Fall sale",
  "campaignStatus": "active",
  "platformStatus": "ENABLED",
  "budget": { "amount": 25, "currency": "USD", "type": "daily" },
  "ads": [
    {
      "adId": "71234567890",
      "approvalStatus": "APPROVED_LIMITED",
      "reviewStatus": "REVIEWED",
      "policyTopics": [{ "topic": "ALCOHOL", "type": "LIMITED" }]
    }
  ]
}
```

```json 200: Performance Max Campaign theme={"system"}
{
  "status": "success",
  "platform": "google",
  "campaignId": "21534567891",
  "name": "Fall sale PMax",
  "campaignStatus": "paused",
  "platformStatus": "PAUSED",
  "budget": { "amount": 40, "currency": "USD", "type": "daily" },
  "ads": [
    {
      "adId": "asset:6512345678~31234567890~HEADLINE",
      "assetId": "31234567890",
      "fieldType": "HEADLINE",
      "primaryStatus": "ELIGIBLE",
      "approvalStatus": "APPROVED",
      "reviewStatus": "REVIEWED",
      "policyTopics": []
    }
  ]
}
```

```json 400: Not Found theme={"system"}
{
  "action": "ads",
  "status": "error",
  "code": 400,
  "message": "Campaign not found or you are not authorized to access it."
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.