Cara Mengirim Gambar via API


Artikel ini merupakan dokumentasi API yang dapat membantu kamu dalam pengembangan serta integrasi ke sistem kamu melalui API alatwa, pastikan kamu telah memiliki API KEY untuk melanjutkan tutorial ini, namun jika kamu belum memiliki API KEY bisa kunjungi halaman cara mendapatkan API KEY.

image for Cara Mengirim Gambar via API

Request

Target URL: https://api.alatwa.com/send/media

Header

  • Content-Type: application/json
  • Authorization: API KEY

Body

{
  "device": "Your Device ID",
  "phone": "WhatsApp Number Receiver",
  "message": "Your Caption",
  "url": "https://is3.cloudhost.id/alatwa.com/assets/img/background-alatwa-com-free-trial-7-days.png"
}

Response

{
  "status": "ok",
  "message_id": "3EB07186F0298BF9E5E8",
  "from": "628129876543",
  "to": "628123456789"
}

Example in PHP

$header = array(
    "Content-Type: application/json",
    "Authorization: Your API KEY"
);

$data = array(
    "device" => "Your Device ID",
    "phone" => "628123456789",
    "message" => "test caption",
    "url" =>  "https://is3.cloudhost.id/alatwa.com/assets/img/background-alatwa-com-free-trial-7-days.png"
);

$param_post = json_encode($data, JSON_PRETTY_PRINT);
$post        = curl_init("https://api.alatwa.com/send/media");
curl_setopt($post, CURLOPT_HTTPHEADER, $header);
curl_setopt($post, CURLOPT_POST, 1);
curl_setopt($post, CURLOPT_POSTFIELDS, $param_post);
curl_setopt($post, CURLOPT_RETURNTRANSFER, true);
curl_setopt($post, CURLOPT_CONNECTTIMEOUT, 0); 
curl_setopt($post, CURLOPT_TIMEOUT, 5);
$response = curl_exec($post);
curl_close($post);
echo $response;

Conclusion

API alatwa dibuat sesimpel mungkin agar mudah dipahami dan diintegrasikan, jika masih ada yang belum dipahami bisa ditanyakan melalui WhatsApp.

**Device ID bisa dilihat di menu device, masing-masing device memiliki Device ID

 

Bagikan:

Artikel Terkait