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

# GeetestIconCrushWebTask

> Giải captcha icon crush Geetest trên web

Captcha icon crush là một loại hình ảnh xác thực phổ biến, yêu cầu người dùng **hoán đổi vị trí hai icon** trong lưới 3×3 sao cho có được 3 icon giống nhau thẳng hàng (ngang, dọc hoặc chéo).

<Frame>
  <img src="https://mintcdn.com/omocaptcha/Jc1mwaiUF23R0W3R/images/geetest-icon-crush-web-modal.png?fit=max&auto=format&n=Jc1mwaiUF23R0W3R&q=85&s=1427feee0c047aab7e031a6eaf462781" style={{ maxWidth: "360px", width: "100%" }} width="337" height="385" data-path="images/geetest-icon-crush-web-modal.png" />
</Frame>

## 1. Tạo yêu cầu

### Request

`POST https://api.omocaptcha.com/v2/createTask`

| Tham số            | Kiểu     | Bắt buộc | Mô tả                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ------------------ | -------- | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `clientKey`        | `String` |     ✅    | Khóa tài khoản khách hàng                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `task.type`        | `String` |     ✅    | Tên class dịch vụ captcha cần giải                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `task.imageBase64` | `String` |     ✅    | Ảnh lưới icon 3×3 được mã hóa base64<br /><br /><img src="https://mintcdn.com/omocaptcha/Jc1mwaiUF23R0W3R/images/geetest-icon-crush-web-image.png?fit=max&auto=format&n=Jc1mwaiUF23R0W3R&q=85&s=36a76e28b005d139f2346621a67f5532" style={{ maxWidth: "260px", width: "100%" }} width="307" height="262" data-path="images/geetest-icon-crush-web-image.png" /> |

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.omocaptcha.com/v2/createTask \
    -H "Content-Type: application/json" \
    -d '{
      "clientKey": "OMO_API_KEY",
      "task": {
        "type": "GeetestIconCrushWebTask",
        "imageBase64": "BASE64_BODY_HERE"
      }
    }'
  ```

  ```javascript Node.js theme={null}
  const res = await fetch("https://api.omocaptcha.com/v2/createTask", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      clientKey: "OMO_API_KEY",
      task: {
        type: "GeetestIconCrushWebTask",
        imageBase64: "BASE64_BODY_HERE"
      }
    })
  });
  console.log(await res.json());
  ```

  ```python Python theme={null}
  import requests

  res = requests.post("https://api.omocaptcha.com/v2/createTask", json={
      "clientKey": "OMO_API_KEY",
      "task": {
          "type": "GeetestIconCrushWebTask",
          "imageBase64": "BASE64_BODY_HERE"
      }
  })
  print(res.json())
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init("https://api.omocaptcha.com/v2/createTask");
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
      "clientKey" => "OMO_API_KEY",
      "task" => [
          "type" => "GeetestIconCrushWebTask",
          "imageBase64" => "BASE64_BODY_HERE"
      ]
  ]));
  echo curl_exec($ch);
  ```
</CodeGroup>

### Response

**Thành công:**

```json theme={null}
{
  "errorId": 0,
  "taskId": "49f9f60a-c809-4af0-93c0-0409b72e67e0"
}
```

Máy chủ trả về `errorId = 0` và `taskId` khi tạo thành công.

**Thất bại:**

```json theme={null}
{
  "errorId": 1,
  "errorCode": "",
  "errorDescription": ""
}
```

Máy chủ trả về `errorId = 1` cùng `errorCode` là mã lỗi tương ứng.

## 2. Nhận kết quả yêu cầu

### Request

`POST https://api.omocaptcha.com/v2/getTaskResult`

```json theme={null}
{
  "clientKey": "OMO_API_KEY",
  "taskId": "49f9f60a-c809-4af0-93c0-0409b72e67e0"
}
```

### Response

**Thành công:**

```json theme={null}
{
  "errorId": 0,
  "errorCode": "",
  "errorDescription": "",
  "status": "ready",
  "solution": {
    "swap_positions": [4, 7]
  }
}
```

Máy chủ trả về `errorId = 0` và `status = ready`. Đọc kết quả trong trường `solution`.

<Tip>
  `solution.swap_positions` là mảng gồm **2 chỉ số ô cần hoán đổi vị trí** trong lưới 3×3. Các ô được đánh số từ **0 đến 8**, tính từ trái sang phải và từ trên xuống dưới (hàng 1: `0, 1, 2` – hàng 2: `3, 4, 5` – hàng 3: `6, 7, 8`). Click hoặc kéo icon ở ô thứ nhất sang ô thứ hai (hoặc ngược lại) để hoàn thành captcha.
</Tip>

**Đang xử lý:**

```json theme={null}
{
  "status": "processing",
  "errorId": 0,
  "errorCode": "",
  "errorDescription": ""
}
```

Máy chủ trả về `errorId = 0` và `status = processing`, vui lòng chờ 2 giây rồi yêu cầu lại.

**Thất bại:**

```json theme={null}
{
  "errorId": 1,
  "errorCode": "ERROR_JOB_STATUS",
  "errorDescription": "Job failed",
  "status": "fail",
  "solution": {}
}
```

Máy chủ trả về `errorId = 1` khi tác vụ thất bại.
