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

# ZaloSliderPhoneTask

> Giải captcha kéo thả mảnh ghép trên app Zalo

Kéo thả trên app là một loại hình ảnh xác thực phổ biến.

<Frame>
  <img src="https://mintcdn.com/omocaptcha/Jc1mwaiUF23R0W3R/images/zalo-slider-phone-modal.png?fit=max&auto=format&n=Jc1mwaiUF23R0W3R&q=85&s=8fa81a14670c47c29ca3db9206f213cc" style={{ maxWidth: "360px", width: "100%" }} width="1080" height="2220" data-path="images/zalo-slider-phone-modal.png" />
</Frame>

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

**Request**

```http theme={null}
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: `ZaloSliderPhoneTask`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `task.imageBase64` | `String` |     ✅    | Hình ảnh chụp màn hình được mã hóa base64 <br /><br /><img src="https://mintcdn.com/omocaptcha/Jc1mwaiUF23R0W3R/images/zalo-slider-phone-modal.png?fit=max&auto=format&n=Jc1mwaiUF23R0W3R&q=85&s=8fa81a14670c47c29ca3db9206f213cc" style={{ maxWidth: "260px", width: "100%" }} width="1080" height="2220" data-path="images/zalo-slider-phone-modal.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": "ZaloSliderPhoneTask",
        "imageBase64": "BASE64_BODY_HERE"
      }
    }'
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');

  const response = await axios.post('https://api.omocaptcha.com/v2/createTask', {
    clientKey: 'OMO_API_KEY',
    task: {
      type: 'ZaloSliderPhoneTask',
      imageBase64: 'BASE64_BODY_HERE'
    }
  });

  console.log(response.data);
  ```

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

  response = requests.post(
      'https://api.omocaptcha.com/v2/createTask',
      json={
          'clientKey': 'OMO_API_KEY',
          'task': {
              'type': 'ZaloSliderPhoneTask',
              'imageBase64': 'BASE64_BODY_HERE'
          }
      }
  )

  print(response.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' => 'ZaloSliderPhoneTask',
          'imageBase64' => 'BASE64_BODY_HERE'
      ]
  ]));

  $response = curl_exec($ch);
  curl_close($ch);
  echo $response;
  ```
</CodeGroup>

**Response**

Thành công:

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

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

Thất bại:

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

Máy chủ sẽ trả về `errorId = 1` cùng với `errorCode` là mã lỗi.

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

**Request**

```http theme={null}
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,
  "status": "ready",
  "solution": {
    "start": {
      "x": 100,
      "y": 250
    },
    "end": {
      "x": 300,
      "y": 250
    }
  }
}
```

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

| Trường             | Kiểu     | Mô tả                                 |
| ------------------ | -------- | ------------------------------------- |
| `solution.start.x` | `Number` | Tọa độ X điểm bắt đầu kéo (mảnh ghép) |
| `solution.start.y` | `Number` | Tọa độ Y điểm bắt đầu kéo (mảnh ghép) |
| `solution.end.x`   | `Number` | Tọa độ X điểm thả (vị trí đích)       |
| `solution.end.y`   | `Number` | Tọa độ Y điểm thả (vị trí đích)       |

<Tip>
  Mô phỏng thao tác chạm trên app: `touchstart` tại `start` → `touchmove` theo quỹ đạo tự nhiên đến `end` → `touchend`. Tránh di chuyển thẳng tuyến tính quá nhanh để giảm khả năng bị phát hiện là bot.
</Tip>

Đang xử lý:

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

Máy chủ sẽ trả về `errorId = 0` và `status = processing` khi yêu cầu đang được xử lý. 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ủ sẽ trả về `errorId = 1` khi xử lý thất bại.
