Berikut ini contoh kode untuk kirim gambar lewat kode PHP.
error_reporting(E_ALL); ini_set('display_errors', true); ini_set('display_startup_errors', true); $requestParam = [ 'phone' => '6289508618321', 'message' => 'Hai', 'type' => 'image', ]; $image_path = '/home/miskat/Pictures/dummy.png'; if (function_exists('curl_file_create')) { // php 5.5+ $requestParam['attachment'] = curl_file_create($image_path); } else { // $requestParam['attachment'] = '@' . realpath($image_path); } $authorization = "Authorization: Bearer e5019269fc899db70106bbd2820ba390"; $url = 'http://atlas.api-wa.my.id/api/message'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array($authorization)); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $requestParam); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSLVERSION, 3); $response = curl_exec($ch); $array_response = json_decode( $response, true ); if (json_last_error() == JSON_ERROR_NONE) { print_r($array_response); }