Send Message Image
Kirim pesan gambar ke nomor whatsapp pribadi atau group.
tip
Kecepatan upload tergantung dari besarnya file yang anda kirimkan, semakin besar maka semakin lama.
Header
Content-Type: multipart/form-data
Request Send to Private
API URL
POST /api/v2/message/send-image
Request Body
Parameter | Type | Status | Description |
---|---|---|---|
phone | string | required | Nomor whatsapp penerima pesan. |
image | file | required | File yang ingin anda kirimkan. Extention: .jpg, .jpeg atau .png |
caption | string | optional | Keterangan gambar |
Request Send to Group
API URL
POST /api/v2/message/send-group-image
Request Body Group
Parameter | Type | Status | Description |
---|---|---|---|
phone | string | required | Nomor whatsapp penerima pesan. |
groupid | string | required | Group ID identification. |
image | file | required | File yang ingin anda kirimkan. Extention: .jpg, .jpeg atau .png |
caption | string | optional | Keterangan gambar |
Example Code
warning
Pastikan anda menyesuaikan URL POST sesuai dengan URL REST API Panel.
Curl (Private)
curl -X POST \
"https://krmpesan.com/api/v2/message/send-image" \
-H "Content-Type: multipart/form-data" \
-H "Accept: application/json" \
-H "Authorization: Bearer {your-token}" \
-F "phone=085712341234" \
-F "caption=Gambar Caption" \
-F "image=@/home/path/files/sample-image.png"
Curl (Group)
curl -X POST \
"https://krmpesan.com/api/v2/message/send-group-image" \
-H "Content-Type: multipart/form-data" \
-H "Accept: application/json" \
-H "Authorization: Bearer {your-token}" \
-F "phone=085712341234" \
-F "groupid=12345678" \
-F "caption=Gambar Caption" \
-F "image=@/home/path/files/sample-image.png"
PHP Curl
<?php
// parse file and get file information
// https://www.php.net/manual/en/function.realpath
$file = realpath('/home/path/files/sample-image.png');
// https://www.php.net/manual/en/function.basename
$filename = basename($file);
// https://www.php.net/manual/en/function.mime-content-type
$filemime = mime_content_type($file);
// start curl
$ch = curl_init();
// post data
// https://www.php.net/manual/en/function.curl-file-create
$post = array(
'phone' => '085712341234',
'caption' => 'Gambar Caption',
'image' => curl_file_create($file, $filemime, $filename)
);
curl_setopt($ch, CURLOPT_URL, 'https://krmpesan.com/api/v2/message/send-image');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$headers = array();
$headers[] = 'Content-Type: multipart/form-data';
$headers[] = 'Accept: application/json';
$headers[] = 'Authorization: Bearer {your-token}';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
var_dump($result);
Response
{
"code": 200,
"message": "Success. Messages will be sent automatically according to the queue and synchronization of contacts. At least 15 minutes for new contacts.",
"data": {
"queue_id": "641",
"uuid": "380a9285-1f4d-4e4b-aa29-932f4695c040",
"user_id": "607a6e33-585e-4f8f-bf5d-d45fe222ad51",
"device_id": "792f656e-4cd7-434b-bab0-bacee3976b4f",
"phone": "6285712341234",
"message": "Gambar Caption",
"attachment_id": "c5b21fd3-b300-4ee9-b4f6-8c19b093ea30",
"type": "Image",
"category": "Outbox",
"status": "Pending",
"updated_at": "2020-04-20 16:35:47",
"created_at": "2020-04-20 16:35:47"
}
}