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

# TiktokSliderPhoneTask

> Giải captcha kéo thả (slider) của Tiktok trên phiên bản phone.

Kéo thả trên phone là một loại hình ảnh xác thực phổ biến. Người dùng cần kéo mảnh ghép nhỏ vào đúng vị trí trên ảnh nền.

<Frame caption="Ví dụ captcha kéo thả của Tiktok trên phone">
  <img src="https://mintcdn.com/omocaptcha/Jc1mwaiUF23R0W3R/images/tiktok-slider-phone-modal.png?fit=max&auto=format&n=Jc1mwaiUF23R0W3R&q=85&s=f96f779b25494b743e3f4c5886558ca4" style={{ maxWidth: "360px", width: "100%" }} width="591" height="1149" data-path="images/tiktok-slider-phone-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 API 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 chụp màn hình được mã hóa base64 <br /><br /><img src="https://mintcdn.com/omocaptcha/Jc1mwaiUF23R0W3R/images/tiktok-slider-phone-modal.png?fit=max&auto=format&n=Jc1mwaiUF23R0W3R&q=85&s=f96f779b25494b743e3f4c5886558ca4" style={{ maxWidth: "260px", width: "100%" }} width="591" height="1149" data-path="images/tiktok-slider-phone-modal.png" /> |

### Code mẫu

<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": "TiktokSliderPhoneTask",
        "imageBase64": "BASE64_BODY_HERE"
      }
    }'
  ```

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

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

  console.log(data);
  ```

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

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

  print(resp.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' => 'TiktokSliderPhoneTask',
          '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ủ 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ủ trả về `errorId = 1` và `errorCode` là mã lỗi tương ứng. Xem danh sách [Mã lỗi](/vi/api/bang-ma-loi).

## 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,
  "status": "ready",
  "solution": {
    "start": {
      "x": 50,
      "y": 30
    },
    "end": {
      "x": 100,
      "y": 70
    },
    "end2": {
      "x": 100,
      "y": 70
    }
  }
}
```

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

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

<Tip>
  Toạ độ được tính theo hệ pixel của ảnh gốc gửi lên. Kết hợp `start` và `end` để tính quãng đường kéo, sau đó mô phỏng thao tác chạm và kéo (touchstart → touchmove → touchend) trên phone với quỹ đạo tự nhiên.
</Tip>

**Đang xử lý:**

```json theme={null}
{
  "errorId": 0,
  "status": "processing",
  "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`. Xem chi tiết tại [Mã lỗi](/vi/api/bang-ma-loi).
