Table of Contents
Request Method | POST |
Endpoint URL | /api/message |
Header Authorization | Bearer token |
Field | Contoh Value | Keterangan |
phone | 62812000000001Kirim ke beberapa nomor sekaligus: 62812000000001,62812000000002,62812000000003 |
wajib format nomor dengan kode negara. Hanya nomor saja tanpa tanda +. |
message | Hello, apa kabar? | wajib Isi pesan |
type | text | wajib tipe pesan. pilihan nilai yaitu: text, image, document |
attachment | Field ini berupa file, bukan text. wajib diisi jika tipe pesan: image dan document |
|
date | 2021-12-12 01:01:01 | Mengirim pesan setelah waktu tertentu. Pastikan fomat tanggal sudah sesuai dengan format Y-m-d H:i:s. |
Contoh Request #
Kirim text
curl -X POST -H "Authorization: Bearer e96ec7012d30be266ba6e6d81e88228d" \ -d 'phone=6289508618321' \ -d 'message=Selamat pagi' \ -d 'type=text' \ http://localhost:3000/api/message
Kirim gambar
curl -X POST -H "Authorization: Bearer e96ec7012d30be266ba6e6d81e88228d" \ -F 'phone=6289508618321' \ -F 'message=Selamat pagi' \ -F 'type=image' \ -F 'attachment=@/home/pasya/project/2021/notif/kirimWA_lite/golang/fireworks.jpg' \ http://localhost:3000/api/message
Contoh penerapan menggunakan kode PHP
$postData = [ 'phone' => '628120000000', 'message' => 'Selamat pagi', 'type' =>'text', ]; $header = [ 'Authorization: Bearer 123456789' ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost:3000/api/message'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_VERBOSE,true); $result = curl_exec ($ch); $curlresponse = json_decode($result, true); var_dump($curlresponse);
Output #
{ "code": 200, "message": "Success", "success": [ { "id": 6, "phone": "6289508618321", } ] }