> ## 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.

# Lấy Chiến dịch

> Đọc trạng thái và ngân sách hằng ngày của một chiến dịch Google Ads, cùng kết quả xét duyệt của Google cho từng quảng cáo hoặc thành phần của chiến dịch.

Lấy một chiến dịch Google Ads mà bạn đã tạo qua Ayrshare: tên, trạng thái, ngân sách hằng ngày và kết quả xét duyệt của Google cho từng quảng cáo của chiến dịch.

## Tham số Header

**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`

## Tham số Path

**id** `string` *required*

`campaignId` được trả về khi bạn tạo chiến dịch.

## Phản hồi

| Trường | Nội dung |
| - | - |
| `campaignId` | Id của chiến dịch |
| `name` | Tên chiến dịch |
| `campaignStatus` | `active` hoặc `paused` |
| `platformStatus` | Trạng thái riêng của Google: `ENABLED`, `PAUSED`, hoặc `REMOVED` đối với chiến dịch đã bị xóa trong Google Ads. Chiến dịch đã bị xóa giữ `campaignStatus` cuối cùng mà bạn đặt qua Ayrshare |
| `budget` | Ngân sách hằng ngày: `amount`, `currency` (đơn vị tiền tệ của tài khoản quảng cáo) và `type` (`daily`) |
| `ads` | Kết quả xét duyệt của Google cho từng quảng cáo (Search) hoặc thành phần (Performance Max). Xem [Xét duyệt quảng cáo](#ad-review) |

## Xét duyệt quảng cáo

Google xét duyệt mọi quảng cáo mới theo các chính sách quảng cáo của mình, thường trong vòng một ngày làm việc. Mỗi dòng trong `ads` chứa:

| Trường | Nội dung |
| - | - |
| `adId` | Id của quảng cáo, như được trả về từ Create |
| `approvalStatus` | Quyết định của Google: `APPROVED`, `APPROVED_LIMITED` (hiển thị có giới hạn, ví dụ không hiển thị ở một số quốc gia), `AREA_OF_INTEREST_ONLY` hoặc `DISAPPROVED`. Cho đến khi Google quyết định, trường này chứa một giá trị khác, chẳng hạn `UNKNOWN` hoặc `UNSPECIFIED` |
| `reviewStatus` | Tình trạng của quá trình xét duyệt, ví dụ `REVIEW_IN_PROGRESS` hoặc `REVIEWED` |
| `policyTopics` | Các chính sách dẫn đến giới hạn hoặc việc không phê duyệt: `[{ "topic": "ALCOHOL", "type": "PROHIBITED" }]` |

Quảng cáo không được phê duyệt sẽ không được phân phối. Hãy thay đổi quảng cáo trong Google Ads, hoặc tạo một chiến dịch mới với văn bản tuân thủ chính sách. `ads` sẽ bị bỏ qua khi không thể đọc kết quả xét duyệt của Google vào thời điểm đó, hoặc khi việc đọc mất hơn vài giây; hãy đọc lại chiến dịch sau.

Mỗi đêm, Ayrshare cũng kiểm tra mọi kết quả xét duyệt và gửi một webhook `ads` với `type: "reviewChanged"` khi quyết định của Google thay đổi. Xem [Ads Action](https://www.ayrshare.com/docs/apis/webhooks/actions.md#ads-action).

## Xét duyệt thành phần

Google xét duyệt riêng từng thành phần của chiến dịch Performance Max. `ads` chứa mỗi thành phần một dòng, với cùng các trường như [xét duyệt quảng cáo](#ad-review), cộng thêm:

| Trường | Nội dung |
| - | - |
| `adId` | Khóa của thành phần trong chiến dịch này: `asset:<assetGroupId>~<assetId>~<fieldType>`, hoặc `asset:<campaignId>~<assetId>~<fieldType>` với thành phần thương hiệu |
| `assetId` | Id của thành phần trên Google |
| `fieldType` | Nơi thành phần được sử dụng, ví dụ `HEADLINE`, `MARKETING_IMAGE`, `SQUARE_MARKETING_IMAGE`, `BUSINESS_NAME` hoặc `LOGO` |
| `primaryStatus` | Thành phần có thể được phân phối hay không, ví dụ `ELIGIBLE` hoặc `NOT_ELIGIBLE` |

Tên doanh nghiệp, logo và logo ngang là các thành phần thương hiệu, được liên kết với chiến dịch thay vì nhóm thành phần. Chúng cũng có dòng ở đây, sau các dòng của nhóm thành phần, với khóa là ID chiến dịch: `asset:<campaignId>~<assetId>~<fieldType>`, trong đó `fieldType` là `BUSINESS_NAME`, `LOGO` hoặc `LANDSCAPE_LOGO`.

## Lỗi

| Mã | Khi nào |
| - | - |
| `400` | Chiến dịch không thuộc về bạn, không tồn tại, hoặc không còn trong tài khoản Google Ads. Cũng xảy ra khi người dùng Google mà bạn liên kết không thể truy cập tài khoản quảng cáo, hoặc quyền truy cập Google Ads đã bị thu hồi. |
| `370` | Google không thể hoàn tất yêu cầu. Hãy thử lại. |

```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.