Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type: application/json; charset=utf-8');
- function compute_signature($url, $data, $password)
- {
- ksort($data);
- $input = $url;
- foreach ($data as $key => $value)
- $input .= ",$key=$value";
- $input .= ",$password";
- return base64_encode(sha1($input, true));
- }
- function is_validated($correct_password)
- {
- $signature = @$_SERVER['HTTP_X_REQUEST_SIGNATURE'];
- if (!$signature)
- {
- return false;
- }
- $is_secure = (!empty($_SERVER['HTTPS']) and filter_var($_SERVER['HTTPS'],
- FILTER_VALIDATE_BOOLEAN));
- $protocol = $is_secure ? 'https' : 'http';
- $full_url = $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
- $correct_signature = compute_signature($full_url, $_POST, $correct_password);
- return $signature === $correct_signature;
- }
- $envayaPass = '1234';
- if (!is_validated($envayaPass))
- {
- header('HTTP/1.1 401 Unauthorized', true, 401);
- echo '{"error":{"message:"Password Salah"}}';
- exit();
- }
- $pesan_keluar = array();
- $pesan_keluar[] = array('to' => '+6285729112015', 'message' => 'Pesan keluar 1');
- $pesan_keluar[] = array('to' => '+6285729112015', 'message' => 'Pesan keluar 2');
- $pesan_keluar[] = array('to' => '+6285729112015', 'message' => 'Pesan keluar 3');
- $pesan_keluar[] = array('to' => '+6285729112015', 'message' => 'Pesan keluar 4');
- $pesan_keluar[] = array('to' => '+6285729112015', 'message' => 'Pesan keluar 5');
- $payload = array('events' => array(array(
- 'event' => 'send',
- 'messages' => $pesan_keluar,
- )));
- echo json_encode($payload);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement