define('APP_PASSWORD', 'APP_PASSWORD'); $logger = new Logger(); try { // Creating a receiver and intialze it with the incomming data $receiver = new SMSReceiver(file_get_contents('php://input')); // Creating a sender // $sender = new SMSSender(SERVER_URL, APP_ID, APP_PASSWORD); $message = $receiver->getMessage(); // Get the message sent to the app $address = $receiver->getAddress(); // Get the phone no from which the message was sent $logger->WriteLog($receiver->getAddress()); // Code for LBS $request = new LbsRequest($LBS_SERVER_URL); $request->setAppId(APP_ID); $request->setAppPassword(APP_PASSWORD); $request->setSubscriberId($address); $request->setServiceType($SERVICE_TYPE); $request->setFreshness($FRESHNESS); $request->setHorizontalAccuracy($HORIZONTAL_ACCURACY); $request->setResponseTime($RESPONSE_TIME); // LBS end list($keyword, $id) = explode(" ", $message); if (isset($id)) { // Code for subscribe subcribe($SUBSCRIPTION_SERVER_URL, APP_ID, APP_PASSWORD, $address); // subscribe end // // Code for LBS $lbsClient = new LbsClient(); $lbsResponse = new LbsResponse($lbsClient->getResponse($request));
$con->mysqlclose(); $data3 = array(); foreach ($data2 as $key => $value) { $log = new KLogger("lbs_debug.log", KLogger::DEBUG); $subscriberId = "tel:" . $value; $log->LogDebug("Received msisdn = " . $subscriberId); $LBS_QUERY_SERVER_URL = 'http://127.0.0.1:7000/lbs/locate'; $APP_ID = "APP_001768"; $PASSWORD = "******"; $SERVICE_TYPE = "IMMEDIATE"; $FRESHNESS = "HIGH"; $HORIZONTAL_ACCURACY = "1500"; $RESPONSE_TIME = "NO_DELAY"; $request = new LbsRequest($LBS_QUERY_SERVER_URL); $request->setAppId($APP_ID); $request->setAppPassword($PASSWORD); $request->setSubscriberId($subscriberId); $request->setServiceType($SERVICE_TYPE); $request->setFreshness($FRESHNESS); $request->setHorizontalAccuracy($HORIZONTAL_ACCURACY); $request->setResponseTime($RESPONSE_TIME); function getModifiedTimeStamp($timeStamp) { try { $date = new DateTime($timeStamp, new DateTimeZone('Asia/Colombo')); } catch (Exception $e) { echo $e->getMessage(); exit(1); } return $date->format('Y-m-d H:i:s'); }
function getLoc($url, $info, $subId) { $locationReq = new LbsRequest($url); $locationReq->setAppId($info["appId"]); $locationReq->setAppPassword($info["password"]); $locationReq->setSubscriberId($subId); $locationReq->setServiceType($info["serviceType"]); $locationReq->setFreshness($info["freshness"]); $locationReq->setHorizontalAccuracy($info["hAccuracy"]); $locationReq->setResponseTime($info["responseTime"]); $lbsClient = new LbsClient(); $lbsResponse = new LbsResponse($lbsClient->getResponse($locationReq)); $lbsResponse->setTimeStamp(getModifiedTimeStamp($lbsResponse->getTimeStamp())); return $lbsResponse; }