34
loading...
This website collects cookies to deliver better user experience
Pastikan kamu sudah memiliki device aktif dan API KEY yang akan digunakan sebagai Authorization.
Buatlah file index.php untuk meletakkan seluruh kode. Salin kode berikut ini kedalam file index.php
Buat file button_action.php
File button_action.php digunakan untuk menerima form dari index.php kemudian mengirim ke alatwa.com dengan cURL.
Salin kode berikut ini kedalam file button_action.php
<?php
$url = '[https://app.alatwa.com/api/send/message/button'](https://app.alatwa.com/api/send/message/button');
$header = array(
'Content-Type: application/json',
'Authorization: API KEY',
);
$params = [
'device' => 'Your Device',
'type' => $_POST['type'],
'phone' => $_POST['phone'],
'message_header' => $_POST['message_header'],
'message' => $_POST['message'],
'message_footer' => $_POST['message_footer'],
'button_1' => $_POST['button_1'],
'button_2' => $_POST['button_2'],
'button_3' => $_POST['button_3'],
];
$params_post = json_encode($params, JSON_PRETTY_PRINT);
$post = curl_init($url);
curl_setopt($post, CURLOPT_HTTPHEADER, $header);
curl_setopt($post, CURLOPT_POSTFIELDS, $params_post);
curl_setopt($post, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($post);
curl_close($post);
echo $response;
{
"status": "OK",
"message_id": "3EB0582ED23A147BA19F",
"from": "6285157757217",
"to": "6285772897870"
}
Gunakan kode negara saat mengisi bagian phone.
Contoh: 085157757217 menjadi 6285157757217
Untuk mendapatkan API KEY, daftar terlebih dahulu pada halaman berikut ini https://app.alatwa.com/register