> For the complete documentation index, see [llms.txt](https://docs.exoclick.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exoclick.com/api/zh/exoclick-gong-gong-api/api-manual-curl-examples.md).

# cURL 示例

## 概述

本指南提供可直接使用的 cURL 命令，用于通过 ExoClick API 进行身份验证和创建广告系列。所有示例根据端点要求使用标准 JSON 或 Form-Data 格式。

## 身份验证（登录）

你可以使用账户凭据或永久 API Token 进行身份验证。两者都会返回一个临时 Bearer Token，供后续所有请求使用。

{% tabs %}
{% tab title="使用用户名和密码登录" %}

```bash
curl -X POST "https://api.exoclick.com/v2/login" \
     -H "Content-Type: application/json" \
     -d '{
       "username": "YOUR_USERNAME",
       "password": "YOUR_PASSWORD"
     }'
```

{% endtab %}

{% tab title="使用 API Token 登录" %}
如果你在 ExoClick 仪表板（[个人资料](https://docs.exoclick.com/docs/general/my-profile/) > API Tokens）中生成了令牌，请使用此方式。

```bash
curl -X POST "https://api.exoclick.com/v2/login" \
     -H "Content-Type: application/json" \
     -d '{
       "api_token": "YOUR_API_TOKEN"
     }'
```

{% endtab %}
{% endtabs %}

## 300x250 横幅广告系列创建流程

请严格按照以下步骤顺序操作。注意最后几步中从 JSON 切换为 Form-Data。

{% stepper %}
{% step %}

### 创建落地页 URL（素材库）

注册你的目标网址。

**格式：** JSON

```bash
curl -X POST "https://api.exoclick.com/v2/library/url" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "url": "https://your-landing-page.com"
     }'
```

**结果：** 保存返回的 `"id"` （例如， `6512406`).
{% endstep %}

{% step %}

### 上传图片（素材库）

注册你的创意素材。图片必须严格为 300x250。

**格式：** 表单数据

```bash
curl -X POST "https://api.exoclick.com/v2/library/file" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -F "file=@/path/to/your/image_300x250.jpg" \
     -F "type=image"
```

**结果：** 保存返回的 `"id"` （例如， `6884966`).
{% endstep %}

{% step %}

### 创建广告系列外壳

设置定向、预算和 `img_banner` 模板。

**格式：** JSON

```bash
curl -X POST "https://api.exoclick.com/v2/campaigns" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
  "name": "Banner 300x250",
  "status": 0,
  "advertiser_ad_type": 0,
  "media_storage_template": "img_banner",
  "size": "300x250",
  "categories": { "type": "targeted", "elements": [97, 98, 99] },
  "countries": {
    "type": "targeted",
    "elements": [{ "country": "USA", "regions": [0] }]
  },
  "pricing": { "model": 4, "price": 300 },
  "start_date": "2026-03-02",
  "daily_limit_type": 1,
  "max_daily_budget": 2000,
  "budget_delivery_mode": 1,
  "run_on_responsive_zones": 1
}'
```

**结果：** 保存返回的 `"id"` （例如， `8140060`).
{% endstep %}

{% step %}

### 添加变体

将 URL（步骤 1）和图片（步骤 2）链接到广告系列（步骤 3）。

**格式：** 表单数据

```bash
curl -X POST "https://api.exoclick.com/v2/campaigns/8140060/variation" \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -F "id_library_url=6512406" \
     -F "id_library_file=6884966" \
     -F "active=1"
```

{% endstep %}
{% endstepper %}

每一步返回的所有 ID 都必须保存并用于后续请求。记得将 `YOUR_TOKEN`、文件路径和 ID 替换为你的实际值。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.exoclick.com/api/zh/exoclick-gong-gong-api/api-manual-curl-examples.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
