UNLOCK API
Seret dan lepas

Seret dan lepas

Cara mengirim tugas Seret dan lepas ke UNLOCK API dengan createTask atau in.php: nama tipe tugas, semua parameter, objek solution, field proxy, dan contoh kode dalam 7 bahasa.
Harga
$0.60 $0.0006 per tugas
Yang Anda kirim
Gambar dan ke mana potongan harus diletakkan
Yang Anda terima
Gerakan yang harus dilakukan (titik asal dan tujuan)

Ringkasan dan harga

Nama tipe tugas

Tipe ini hanya punya satu nama.
DragAndDropTask

Objek task

type
StringWajib
Nama tipe tugas. Huruf besar atau kecil tidak berpengaruh. DragAndDropTask
body
StringWajib
Gambar sebagai base64 (JPG, PNG, atau GIF), hingga sekitar 100 KB. Awalan data: diperbolehkan.
comment
StringOpsional
Instruksi untuk pemecah, misalnya pertanyaan yang tampil di atas gambar.

Field yang tidak tercantum di sini diteruskan ke pemecah apa adanya.

Request

POST /createTask
{
  "clientKey": "YOUR_API_KEY",
  "task": {
    "type": "DragAndDropTask",
    "body": "/9j/4AAQSkZJRgABAQ...",
    "comment": "Move each piece to its matching place"
  }
}

Objek solution

Dikembalikan di solution saat status ready.
answer
Array
Jawaban yang dikirim.
POST /getTaskResult
{
  "errorId": 0,
  "taskId": 1001,
  "status": "ready",
  "solution": {
    "answer": [
      {
        "from": {
          "x": 20,
          "y": 40
        },
        "to": {
          "x": 210,
          "y": 44
        }
      }
    ]
  },
  "cost": "0.0006",
  "createTime": 1791640000,
  "endTime": 1791640014,
  "solveCount": 1
}

Contoh kode

import time, requests

API = "https://unlock-api.com"
KEY = "YOUR_API_KEY"

task = requests.post(f"{API}/createTask", json={
    "clientKey": KEY,
    "task": {
      "type": "DragAndDropTask",
      "body": "/9j/4AAQSkZJRgABAQ...",
      "comment": "Move each piece to its matching place"
    }
}).json()
if task["errorId"]:
    raise SystemExit(task["errorCode"])

for _ in range(60):   # 60 x 5 s = the 5 minute task limit
    time.sleep(5)
    r = requests.post(f"{API}/getTaskResult", json={"clientKey": KEY, "taskId": task["taskId"]}).json()
    if r["errorId"]:
        raise SystemExit(f"{r['errorCode']}: {r.get('errorDescription', '')}")   # failed tasks are refunded
    if r["status"] == "ready":
        print(r["solution"])
        break
else:
    raise SystemExit("timed out")

Metode form in.php

Tipe ini hanya tersedia lewat metode JSON.