$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)); $lbsResponse->setTimeStamp(getModifiedTimeStamp($lbsResponse->getTimeStamp())); //Changing the timestamp format. Ex: from '2013-03-15T17:25:51+05:30' to '2013-03-15 17:25:51' // LBS end //DB save $saveBin = "INSERT INTO red_firediv(div_id,tel_no,type,latitude,longitude,alt_time) VALUES('" . $id . "','" . $address . "','fire','" . $lbsResponse->getLatitude() . "','" . $lbsResponse->getLongitude() . "','" . $lbsResponse->getTimeStamp() . "')"; $ccc = mysqli_query($connection, $saveBin); if (mysqli_error($connection)) { $logger->WriteLog(mysqli_error($connection)); } //http post request } else { } } catch (SMSServiceException $e) { $logger->WriteLog($e->getErrorCode() . ' ' . $e->getErrorMessage()); } function getModifiedTimeStamp($timeStamp)
$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'); } $lbsClient = new LbsClient(); $lbsResponse = new LbsResponse($lbsClient->getResponse($request)); $lbsResponse->setTimeStamp(getModifiedTimeStamp($lbsResponse->getTimeStamp())); //Changing the timestamp format. Ex: from '2013-03-15T17:25:51+05:30' to '2013-03-15 17:25:51' $log->LogDebug("Lbs response:" . $lbsResponse->toJson()); $gps = $lbsResponse->toJson(); //$gps=$data[$key].",".$gps; array_push($data3, $gps); } //print_r($data3); foreach ($data3 as $key => $value) { $data4 = explode(',', $value); //print_r($data4); $epc = $data[$key]; echo $epc; $time = time(); //explode(':',$data4[1]); $h = explode('"', $data4[4]);
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; }