Overview
GET
/api/{mid}/getContactsดึงรายชื่อเพื่อน/บัญชีที่เกี่ยวข้องกับ MID
POST
/api/{mid}/getMessagesดึงข้อความย้อนหลังในกล่องสนทนาระบุ messageBoxId
GET /api/{mid}/getContacts
Method: GET
Endpoint: https://line-api.cz.in.th/api/{mid}/getContacts
| พารามิเตอร์ | ตำแหน่ง | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|---|
mid | Path | string | ✅ | MID ของบัญชีหลักที่ใช้ดึงข้อมูล |
Headers
| ชื่อ | ค่า | จำเป็น |
|---|---|---|
Content-Type | application/json | ✅ |
สถานะตอบกลับ
| HTTP | ความหมาย |
|---|---|
| 200 | สำเร็จ – ได้ลิสต์ contacts |
'https://line-api.cz.in.th/api/{mid}/getContacts',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
const mid = "{mid}";
fetch(\`https://line-api.cz.in.th/api/\${mid}/getContacts\`)
.then(r => r.json())
.then(console.log)
.catch(console.error);
[
{
"mid": "{mid}",
"createdTime": 1759612792756,
"type": "MID",
"status": "FRIEND",
"relation": "ONEWAY",
"displayName": "🐢",
"pictureStatus": "0Hhgerz...KHB DTX1w",
"statusMessage": "",
"favoriteTime": 0,
"capableVoiceCall": false,
"capableVideoCall": false,
"capableBuddy": false,
"attributes": 0,
"settings": 0,
"picturePath": "/0Hhgerz...KHB DTX1w",
"statusMessageContentMetadata": {},
"nftProfile": false,
"profileId": "rjm_M8K4K24Dt1zfc..."
}
]
POST /api/{mid}/getMessages
Method: POST
Endpoint: https://line-api.cz.in.th/api/{mid}/getMessages
| พารามิเตอร์ | ตำแหน่ง | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|---|
mid | Path | string | ✅ | MID ของบัญชีหลัก |
Body (JSON)
| ชื่อ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
messageBoxId | string | ✅ | MID ของคู่สนทนา (ได้จาก getContacts) |
messagesCount | integer | ✅ | จำนวนข้อความย้อนหลังกี่รายการ |
Headers
| ชื่อ | ค่า | จำเป็น |
|---|---|---|
Content-Type | application/json | ✅ |
'https://line-api.cz.in.th/api/{mid}/getMessages',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"messageBoxId": "{messageBoxId}",
"messagesCount": 50
}',
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
const mid = "{mid}";
const body = { messageBoxId: "{mid}", messagesCount: 50 };
fetch(\`https://line-api.cz.in.th/api/\${mid}/getMessages\`, {
method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body)
}).then(r => r.json()).then(console.log).catch(console.error);
{
"messageBoxId": "{messageBoxId}",
"messagesCount": 50,
"nextBeforeId": "581806598689477735",
"messages": [
{
"id": "581806598689477735",
"createdTime": 1759614696845,
"from": "{mid}",
"to": "{mid}",
"contentType": null,
"text": ":ping"
},
{
"id": "581808599269894825",
"createdTime": 1759614697842,
"from": "{mid}",
"to": "{mid}",
"text": "👋 got it"
}
]
}
ตัวอย่างการใช้งานเร็ว ๆ
เปลี่ยนค่า {mid} และ messageBoxId ให้ตรงกับระบบของคุณ
# Contacts
curl -s 'https://line-api.cz.in.th/api/{mid}/getContacts'
# Messages (50 รายการล่าสุด)
curl -s -X POST 'https://line-api.cz.in.th/api/{mid}/getMessages' -H 'Content-Type: application/json' -d '{ "messageBoxId": "uXXXXXXXXXXXX", "messagesCount": 50 }'