<?php
$url = 'http://localhost:3000';


$ch = curl_init($url);

// Setup request to send json via POST
$data = array('sms' =>$message,'mobile' =>$mn,'id' =>$id);
//echo "<pre>";print_r($data);exit;
$payload = json_encode($data);

// Attach encoded JSON string to the POST fields
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

// Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

// Return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the POST request
$result = curl_exec($ch);
$result = json_decode($result, true);

$ackid= $result['id']; // acknoledge id from SMS serivces.

// echo "<pre>";print_r($result['id']);exit;

// Close cURL resource
curl_close($ch);
  $sql =    "UPDATE SMSSLC 
                     set ack = 1 where id = ".$ackid;
$stmt4    =  sqlsrv_query( $conn, $sql);


//--------------log file Start-------//

	// $ipname= "Remote IP Address:-";

	
	$datetime      = date("Y-m-d H:i:s");
	$name          = "DATE TIME STAMP:- ";

	$ename         = "  MESSAGE:- ";
	$ack         = "  ACKNOWLEDGE SMS ID:".$ackid;
	$SMS           = "  ALARM SMS:".$ls;
	$SMSNO         = "  ALARM SMS NUMBER:".$mn;



   $filename = ROOT_LOGSPATH1;

   // echo  $filename ;
	$logfile = fopen($filename,"a");
	fwrite($logfile,"\n");
	fwrite($logfile,$name.$datetime);
	fwrite($logfile,$ename.$ack.$SMSNO);
	fclose($logfile);



//--------------log file End-------//
?>$url = 'http://localhost:3000';


$ch = curl_init($url);

// Setup request to send json via POST
$data = array('sms' =>$message,'mobile' =>$mn,'id' =>$id);
//echo "<pre>";print_r($data);exit;
$payload = json_encode($data);

// Attach encoded JSON string to the POST fields
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

// Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

// Return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the POST request
$result = curl_exec($ch);
$result = json_decode($result, true);

$ackid= $result['id']; // acknoledge id from SMS serivces.

// echo "<pre>";print_r($result['id']);exit;

// Close cURL resource
curl_close($ch);
  $sql =    "UPDATE SMSSLC 
                     set ack = 1 where id = ".$ackid;
$stmt4    =  sqlsrv_query( $conn, $sql);


//--------------log file Start-------//

	// $ipname= "Remote IP Address:-";

	
	$datetime      = date("Y-m-d H:i:s");
	$name          = "DATE TIME STAMP:- ";

	$ename         = "  MESSAGE:- ";
	$ack         = "  ACKNOWLEDGE SMS ID:".$ackid;
	$SMS           = "  ALARM SMS:".$ls;
	$SMSNO         = "  ALARM SMS NUMBER:".$mn;



   $filename = ROOT_LOGSPATH1;

   // echo  $filename ;
	$logfile = fopen($filename,"a");
	fwrite($logfile,"\n");
	fwrite($logfile,$name.$datetime);
	fwrite($logfile,$ename.$ack.$SMSNO);
	fclose($logfile);



//--------------log file End-------//