diff --git a/src/Service/RisingTideGateway.php b/src/Service/RisingTideGateway.php index 5928e72e..0681edd4 100644 --- a/src/Service/RisingTideGateway.php +++ b/src/Service/RisingTideGateway.php @@ -37,60 +37,61 @@ class RisingTideGateway $clean_num = $this->cleanPhoneNumber($mobile_num); if ($clean_num === false) - error_log('Invalid mobile number provided. Cannot send SMS message to ' . $mobile_num); - else { - $headers = [ - 'Content-Type: application/vnd.net.wyrls.Document-v3+json' - ]; - - $sms = new SMSMessage(); - $sms->setFrom($this->shortcode) - ->setFromAlias($mask) - ->setTo($clean_num) - ->setMessage($message) - ->setStatus('sent'); - - $this->em->persist($sms); - $this->em->flush(); - - $date = $sms->getDateCreate(); - // $date = new DateTime(); - $date_string = $date->format('Y-m-d') . 'T' . $date->format('H:m:s'); - - $data = [ - 'id' => $sms->getID(), - 'from' => $this->shortcode, - 'from_alias' => $mask, - 'to' => $clean_num, - 'content_type' => 'text/plain', - 'body' => $message, - 'date' => $date_string, - 'usagetype' => $this->usage_type, - 'delivery_receipt_url' => $this->dr_url, - ]; - error_log(print_r($data, true)); - - $data_json = json_encode($data); - - $userpwd = $this->user . ':' . $this->pass; - - $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, self::SERVER_URL); - curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - curl_setopt($curl, CURLOPT_VERBOSE, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $data_json); - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); - curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - curl_setopt($curl, CURLOPT_USERPWD, $userpwd); - $result = curl_exec($curl); - error_log('error_no - ' . curl_errno($curl)); - $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); - error_log($http_code); - curl_close($curl); - - error_log($result); + error_log('Invalid mobile number provided. Cannot send SMS message to ' . $mobile_num); + return; } + + $headers = [ + 'Content-Type: application/vnd.net.wyrls.Document-v3+json' + ]; + + $sms = new SMSMessage(); + $sms->setFrom($this->shortcode) + ->setFromAlias($mask) + ->setTo($clean_num) + ->setMessage($message) + ->setStatus('sent'); + + $this->em->persist($sms); + $this->em->flush(); + + $date = $sms->getDateCreate(); + // $date = new DateTime(); + $date_string = $date->format('Y-m-d') . 'T' . $date->format('H:m:s'); + + $data = [ + 'id' => $sms->getID(), + 'from' => $this->shortcode, + 'from_alias' => $mask, + 'to' => $clean_num, + 'content_type' => 'text/plain', + 'body' => $message, + 'date' => $date_string, + 'usagetype' => $this->usage_type, + 'delivery_receipt_url' => $this->dr_url, + ]; + error_log(print_r($data, true)); + + $data_json = json_encode($data); + + $userpwd = $this->user . ':' . $this->pass; + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, self::SERVER_URL); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + curl_setopt($curl, CURLOPT_VERBOSE, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $data_json); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + curl_setopt($curl, CURLOPT_USERPWD, $userpwd); + $result = curl_exec($curl); + error_log('error_no - ' . curl_errno($curl)); + $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); + error_log($http_code); + curl_close($curl); + + error_log($result); } public function validatePhoneNumber($mobile)