Jump to content

Recommended Posts

Hi,

 

The attached PHP code (2 PHP files) is not working. Please help me out.

 

-- Shehab

 

The Error:

=======

 

Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in C:\xampp\htdocs\onushondhan\core\SMSEventProcessor.php on line 12

 

The SMSEventProcessor.php file:

========================

<?php
include_once('../types/SMSEventOutput.php');
include_once('../types/SMSEventInput.php');
include_once('../types/SMSEventVO.php');
include_once('../datamodel/DataModel001.php');
include_once('SMSEventProcessHelper.php');


class SMSEventProcessor{
	// Instance variables
	// The SMS Event input to work with
	private SMSEventInput $smsEventInput;

	function __construct(SMSEventInput $smsEventInput){
		$this->smsEventInput = $smsEventInput;
	}

	function processSMSEvent(){
		SMSEventProcessHelper $smsEventProcessHelper = new SMSEventProcessHelper($this->smsEventInput);
		SMSEventOutput $smsEventOutput = $smsEventProcessHelper->executeHelper();
	}


}


?>

 

 

The SMSEventProcessHelper.php file:

===========================

<?php
include_once('../types/SMSEventOutput.php');
include_once('../types/SMSEventInput.php');
include_once('../types/SMSEventVO.php');
include_once('../core/ActionHelper.php');
include_once('../datamodel/DataModel001.php');



	class SMSEventProcessHelper extends ActionHelper{
		private SMSEventInput $smsEventInput;
		private SMSEventOutput $smsEventOutput;
		private SMSEventVO $smsEventVO;

		/* Incoming message id */
		private $incomingMessageId;
		/* Mobile number */
		private $mobileNumber;
		/* Original message */
		private $message;
		/* Security code */
		private $securityCode;

		function __construct(SMSEventInput $smsEventInput){
			$this->smsEventInput = $smsEventInput;
		} // End of constructor


		function init(){
			// Setting the instance variables
			$this->smsEventVO = $this->smsEventInput->smsEventVO;
			$this->incomingMessageId = $this->smsEventVO->$incomingMessageId;
			$this->mobileNumber = $this->smsEventVO->$mobileNumber;
			$this->message = $this->smsEventVO->$message;
			$this->securityCode = $this->smsEventVO->$securityCode;
		} // End of init()

		function preValidate(){
			// Checking if the incoming message id is in valid format
			// Yet to get the pre-validation scheme from MuthoFun

			// Checking if the mobile number is in valid format
			// Checking if the number is 11 digits long
			if(strlen($this->mobileNumber) != 11){
				$smsEventOutput->returnCode = SMSEventOutput::$RETURN_CODE_PHONE_NUMBER_LENGTH_ERROR;
				return false;
			}

			// Checking if the number starts with 880
			if(strcmp(substr($this->mobileNumber, 0, 3), "880") != 0){
				$smsEventOutput->returnCode = SMSEventOutput::$RETURN_CODE_PHONE_NUMBER_COUNTRY_CODE_ERROR;
				return false;
			}
			// Checking if the message is in correct format
			if(strlen($this->message) < 7){
				$smsEventOutput->returnCode = SMSEventOutput::$RETURN_CODE_ZERO_MESSAGE_LENGTH_ERROR;
				return false;
			}

			// Checking if the security code is in valid format
			if($this->securityCode != SMSEventVO::$securityCode){
				$smsEventOutput->returnCode = SMSEventOutput::$RETURN_CODE_WRONG_SECURITY_CODE_ERROR;
				return false;
			}
		} // End of preValidate()


		function validate(){
			// Check if it is a meaningful sms
			$tempString = substr($this->mobileNumber, 0, 7);

			// Define headers
			$tempUserRegSMSHeader = "BLD REG";
			$tempUserReqSMSHeaderAPositive = "BLD A+ ";
			$tempUserReqSMSHeaderANegative = "BLD A- ";
			$tempUserReqSMSHeaderBPositive = "BLD B+ ";
			$tempUserReqSMSHeaderBNegative = "BLD B- ";
			$tempUserReqSMSHeaderABPositive = "BLD AB+";
			$tempUserReqSMSHeaderABNegative = "BLD AB-";
			$tempUserReqSMSHeaderOPositive = "BLD O+";
			$tempUserReqSMSHeaderONegative = "BLD O-";

			if(strcmp($tempString, $tempUserRegSMSHeader) != 0 && strcmp($tempString, $tempUserReqSMSHeaderAPositive) != 0 && strcmp($tempString, $tempUserReqSMSHeaderANegative) != 0 && strcmp($tempString, $tempUserReqSMSHeaderBPositive) != 0 && strcmp($tempString, $tempUserReqSMSHeaderBNegative) != 0 && strcmp($tempString, $tempUserReqSMSHeaderABPositive) != 0 && strcmp($tempString, $tempUserReqSMSHeaderABNegative) != 0 && strcmp($tempString, $tempUserReqSMSHeaderOPositive) != 0 && strcmp($tempString, $tempUserReqSMSHeaderONegative) != 0){
				$smsEventOutput->returnCode = SMSEventOutput::$RETURN_CODE_INVALID_KEYWORDS_ERROR;
				return false;
			}
		} // End of validate()

		function loadInternalObjects(){

		} // End of loadInternalObjects

		function executeHelper(){
			$returnMessage = "";

			$returnMessagePrefix = "";
			$returnMessageSuffix = "Powered by Onushondhan.";
			$errorMessage = "This service is not available. Thanks!";
			$newLine = "\n";
			$whiteSpace = " ";
			$colon = ":";

			init();
			if(preValidate() == false){
				if($smsEventOutput->returnCode == SMSEventOutput::$RETURN_CODE_PHONE_NUMBER_LENGTH_ERROR){
					$returnMessage = $returnMessage . "Phone number length should be 11.";
				} else if($smsEventOutput->returnCode == SMSEventOutput::$RETURN_CODE_PHONE_NUMBER_COUNTRY_CODE_ERROR){
					$returnMessage = $returnMessage . "Sorry! Now we are not accepting SMS from overseas network.";
				} else if($smsEventOutput->returnCode == SMSEventOutput::$RETURN_CODE_ZERO_MESSAGE_LENGTH_ERROR){
					$returnMessage = $returnMessage . "Sorry! Now we are not accepting SMS from overseas network.";
				} else if($smsEventOutput->returnCode == SMSEventOutput::$RETURN_CODE_WRONG_SECURITY_CODE_ERROR){
					$returnMessage = $returnMessage . "Oops security code doesn't match!";
				}
			} else  if(validate() == false){
				if($smsEventOutput->returnCode == SMSEventOutput::$RETURN_CODE_INVALID_KEYWORDS_ERROR){
					$returnMessage = $returnMessage . "Type help to know the correct keywords.";
				}
			} else {
				$smsEventOutput->returnCode = SMSEventOutput::$RETURN_CODE_SMS_EVENT_SUCCESSFUL;
				loadInternalObjects();
				// Seperate the message header
				$subMessage = substr($message, 0, 7);
				// Make it lower case
				$subMessage = strtolower($subMessage);



				switch ($subMessage) {
					case "bld adm":
					$dataModel = new DataModel001();
					$dataModel->execute();
    						$returnMessage = $returnMessage . "You are an admin I see.";
    						break;
					case "bld reg":
    						$returnMessage = $returnMessage . "Thanks for your interest. Check back later to register.";
    						break;
					case "bld edt":
    						$returnMessage = $returnMessage . "We are yet to allow you to edit.";
						break;
					case "bld a+ ":
    						$returnMessage = $returnMessage . "Dear A+ Owner, please have some more patience.";
						break;
					case "bld a- ":
    						$returnMessage = $returnMessage . "Dear A- Owner, please have some more patience.";
						break;
					case "bld b+ ":
    						$returnMessage = $returnMessage . "Dear B+ Owner, please have some more patience.";
						break;
					case "bld b- ":
    						$returnMessage = $returnMessage . "Dear B- Owner, please have some more patience.";
						break;
					case "bld ab+":
    						$returnMessage = $returnMessage . "Dear AB+ Owner, please have some more patience.";
						break;
					case "bld ab-":
    						$returnMessage = $returnMessage . "Dear AB- Owner, please have some more patience.";
						break;
					case "bld o+":
    						$returnMessage = $returnMessage . "Dear O+ Owner, please have some more patience.";
						break;
					case "bld o-":
    						$returnMessage = $returnMessage . "Dear O- Owner, please have some more patience.";
						break;
    				
				} // Switch ends

			}// Else clause completes

	$returnMessage = $returnMessagePrefix . $whiteSpace . $returnMessage . $whiteSpace . $colon . $colon . $returnMessageSuffix;
	$smsEventOutput->message = $returnMessage;
	$smsEventOutput->outMessageId = 1;
	$smsEventOutput->outMessageId = 1;
	$smsEventOutput->targetMobileNumber = $this->mobileNumber;
	$smsEventOutput->incomingMessageId = $this->incomingMessageId;
	$smsEventOutput->messageType; = 4;
	$smsEventOutput->securityCode = $this->securityCode;

			return $smsEventOutput;
		}// End of execute helper	




		function addTransaction(){

		}



	function processAdminSMS(SMSEventVO $smsEventVO){

	}
			} // SMSEventProcessHelper

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.