Files
manjapro_v6/webhook_cloud_api/send_to_app2.php
T

29 lines
857 B
PHP

<?php
function forwardToApp2($payload)
{
// URL endpoint di aplikasi 2 (CI3)
$endpoint = 'http://172.16.254.226/webhook/send';
// Encode payload ke JSON
$data_string = json_encode($payload);
// Kirim dengan CURL
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string)
]);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// // Log hasil kirim
// file_put_contents('forward_log.txt', date('Y-m-d H:i:s') . " | HTTP $httpCode | " . $result . "\n", FILE_APPEND);
return $httpCode == 200;
}