Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 71 |
CRAP | |
0.00% |
0 / 2578 |
| SMSService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 71 |
198470.00 | |
0.00% |
0 / 2578 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| __clone | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| getInstance | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 5 |
|||
| searchSMSLog | |
0.00% |
0 / 1 |
600.00 | |
0.00% |
0 / 106 |
|||
| createSMSLog | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 14 |
|||
| getSMSProviderDetails | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 47 |
|||
| getSMSProviderDetailsByModuleId | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 26 |
|||
| getSMSProviderAttributeValue | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 13 |
|||
| parseAPIResponse | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 20 |
|||
| processCreatelogSMS | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 17 |
|||
| sendSMS | |
0.00% |
0 / 1 |
3782.00 | |
0.00% |
0 / 195 |
|||
| sendSMSViaRitsGateway | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 34 |
|||
| sendSMSViaXPRESSSMS | |
0.00% |
0 / 1 |
306.00 | |
0.00% |
0 / 81 |
|||
| sendSMSViaGLOZNET | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 22 |
|||
| sendSMSViaTECHSOL | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 31 |
|||
| sendSMSViaBHASHSMS | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 39 |
|||
| sendSMSViaZORZACORP | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 33 |
|||
| sendSMSViaMithra | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 33 |
|||
| sendSMSViaBULKSMS | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 51 |
|||
| sendSMSViaSCHOOLSERVESMS | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 52 |
|||
| sendSMSViaSCHOOLSERVESMSV1_3 | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 35 |
|||
| sendSMSViaMYSMSMANTRA | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 32 |
|||
| sendSMSViaSMSGUPSHUP | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 53 |
|||
| sendSMSViaMOBTEXTING | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 32 |
|||
| sendSMSViaSMSCOUNTRY | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 48 |
|||
| sendSMSViaSMSAVEON | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 33 |
|||
| sendSMSViaAastha | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 46 |
|||
| sendSMSViaAventsms | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 34 |
|||
| sendSMSViaHindustanSoft | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 35 |
|||
| sendSMSViaBULKSMSGREENADS | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 35 |
|||
| sendSMSViaSAPTELESERVICES | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 48 |
|||
| sendSMSViaFastSMS | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 36 |
|||
| sendSMSViaBlessSMS | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 39 |
|||
| sendSMSViaMoplet | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 37 |
|||
| sendSMSViaRefined | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 35 |
|||
| sendSMSViaPRPSMS | |
0.00% |
0 / 1 |
90.00 | |
0.00% |
0 / 41 |
|||
| sendSMSViaMERABT | |
0.00% |
0 / 1 |
72.00 | |
0.00% |
0 / 57 |
|||
| sendSMSViaSuperSMSIdea | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 36 |
|||
| sendSMSViaRubySoft | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 37 |
|||
| sendSMSViaSMSServer | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 31 |
|||
| sendSMSViaBsnlServer | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 31 |
|||
| sendSMSViaMdsMedia | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 35 |
|||
| sendSMSViaExtremaa | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 32 |
|||
| sendSMSViaSMSU | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 30 |
|||
| sendSMSViaTheParentAlert | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 37 |
|||
| sendSMSViaKalerya | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 35 |
|||
| sendSMSViaRoundSms | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 24 |
|||
| sendSMSViaBulkSmsCochin | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 33 |
|||
| sendSMSFirstDial | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 36 |
|||
| sendSMSAlert | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 29 |
|||
| sendSMSSAC | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 29 |
|||
| sendSMSViaSagarHosting | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 37 |
|||
| sendSMSViaMTALKS | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 34 |
|||
| sendSMSViaSKYPIXELS | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 36 |
|||
| sendSMSViaICECUBE | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 33 |
|||
| sendSMSViaTXTLOCAL | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 21 |
|||
| sendSMSSANGAMAM | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 32 |
|||
| sendSMSMsg91 | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 33 |
|||
| use_getleadSMS | |
0.00% |
0 / 1 |
56.00 | |
0.00% |
0 / 39 |
|||
| use_getSMSBITS | |
0.00% |
0 / 1 |
72.00 | |
0.00% |
0 / 41 |
|||
| use_getSMSAASTHA | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 38 |
|||
| use_getDATAGENIT | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 36 |
|||
| sendSMSViaINSTAALERT | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 33 |
|||
| sendSMSViaADLINKS | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 36 |
|||
| SendSMSViaCLARETCLG | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 34 |
|||
| sendSMSViaMySmsBasket | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 40 |
|||
| sendSMSViaEASYWAYSMS | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 38 |
|||
| sendSMSViaMdsSend | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 35 |
|||
| callSendSMSAPIPost | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 6 |
|||
| callSendSMSAPIGet | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 8 |
|||
| validateSMSRequest | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 14 |
|||
| <?php | |
| namespace com\linways\core\ams\professional\service; | |
| use com\linways\base\dto\sms\SMS; | |
| use com\linways\base\exception\SMSException; | |
| use com\linways\core\ams\professional\exception\ProfessionalException; | |
| use com\linways\base\dto\sms\SMSProvider; | |
| use com\linways\core\ams\professional\mapper\SMSServiceMapper; | |
| use Unirest\Request\Body; | |
| use Unirest\Request; | |
| use com\linways\base\dto\sms\SMSResponse; | |
| use com\linways\core\ams\professional\dto\SMSLog; | |
| use com\linways\core\ams\professional\response\SearchSMSLogResp; | |
| use com\linways\core\ams\professional\request\SearchSMSLogReq; | |
| class SMSService extends BaseService | |
| { | |
| // /Condition 1 - Presence of a static member variable | |
| private static $_instance = null; | |
| private $mapper = []; | |
| // /Condition 2 - Locked down the constructor | |
| private function __construct() | |
| { | |
| $this->mapper = SMSServiceMapper::getInstance()->getMapper(); | |
| // $GLOBALS['ProviderDetails']; | |
| } | |
| // Prevent any oustide instantiation of this class | |
| // /Condition 3 - Prevent any object or instance of that class to be cloned | |
| private function __clone() | |
| {} | |
| // Prevent any copy of this object | |
| // /Condition 4 - Have a single globally accessible static method | |
| public static function getInstance() | |
| { | |
| if (! is_object(self::$_instance)) // or if( is_null(self::$_instance) ) or if( self::$_instance == null ) | |
| self::$_instance = new self(); | |
| return self::$_instance; | |
| } | |
| /** | |
| * Method for search sms log | |
| * @param SearchSMSLogReq $searchSMSLogReq | |
| * @throws ProfessionalException | |
| * @return \com\linways\core\ams\professional\response\SearchSMSLogResp | |
| */ | |
| public function searchSMSLog(SearchSMSLogReq $searchSMSLogReq) | |
| { | |
| $searchSMSLogReq = $this->realEscapeObject($searchSMSLogReq); | |
| $response = new SearchSMSLogResp(); | |
| $sql = "Select sl.id, | |
| sl.context, | |
| sl.createdDate, | |
| sl.message, | |
| sl.mobileNos, | |
| sl.module, | |
| sl.smsProviderCode, | |
| sl.status, | |
| sl.statusDetails, | |
| sl.createdBy, | |
| sl.createdByUserType, | |
| (case | |
| when sa.staffID is not null then sa.staffName | |
| when aa.adminID is not null then aa.adminName | |
| when ha.adminID is not null then ha.adminName | |
| when ada.adminID is not null then ada.adminName | |
| else | |
| 'SYSTEM' end) as userName | |
| from SMSLog sl left join staffaccounts sa on sl.createdBy = sa.staffID and sl.createdByUserType = 'STAFF' | |
| left join adminaccount aa on aa.adminID = sl.createdBy and sl.createdByUserType = 'ADMIN' | |
| left join hr_admin ha on ha.adminID = sl.createdBy and sl.createdByUserType = 'HR_ADMIN' | |
| left join admission_admin ada on ada.adminID = sl.createdBy and sl.createdByUserType = 'ADMISSION_ADMIN' | |
| where 1=1 "; | |
| $sqlCount = "Select count(sl.id) as totalRecords | |
| from SMSLog sl left join staffaccounts sa on sl.createdBy = sa.staffID and sl.createdByUserType = 'STAFF' | |
| left join adminaccount aa on aa.adminID = sl.createdBy and sl.createdByUserType = 'ADMIN' | |
| left join hr_admin ha on ha.adminID = sl.createdBy and sl.createdByUserType = 'HR_ADMIN' | |
| left join admission_admin ada on ada.adminID = sl.createdBy and sl.createdByUserType = 'ADMISSION_ADMIN' | |
| where 1=1 "; | |
| $criteria = ''; | |
| $sortOrder = ""; | |
| $limit = ''; | |
| try { | |
| if (! empty($searchSMSLogReq)) { | |
| if (! empty($searchSMSLogReq->module)) { | |
| $criteria .= " AND module = '$searchSMSLogReq->module'"; | |
| } | |
| if (! empty($searchSMSLogReq->context)) { | |
| $criteria .= " AND context = '$searchSMSLogReq->context'"; | |
| } | |
| if (! empty($searchSMSLogReq->message)) { | |
| $criteria .= " AND message like '%$searchSMSLogReq->message%'"; | |
| } | |
| if (! empty($searchSMSLogReq->mobileNos)) { | |
| $criteria .= " AND mobileNos like '%$searchSMSLogReq->mobileNos%'"; | |
| } | |
| if (! empty($searchSMSLogReq->smsProviderCode)) { | |
| $criteria .= " AND smsProviderCode = '$searchSMSLogReq->smsProviderCode'"; | |
| } | |
| if (! empty($searchSMSLogReq->startDate) && ! empty($searchSMSLogReq->endDate)) { | |
| $criteria .= " AND sl.createdDate BETWEEN '$searchSMSLogReq->startDate' AND '$searchSMSLogReq->endDate'"; | |
| } | |
| if (! empty($searchSMSLogReq->startDate) && empty($searchSMSLogReq->endDate)) { | |
| $criteria .= " AND sl.createdDate >= '$searchSMSLogReq->startDate' "; | |
| } | |
| if (! empty($searchSMSLogReq->endDate) && empty($searchSMSLogReq->startDate)) { | |
| $criteria .= " AND sl.createdDate <= '$searchSMSLogReq->endDate' "; | |
| } | |
| if (! empty($searchSMSLogReq->id)) { | |
| $criteria .= " AND sl.id = '$searchSMSLogReq->id' "; | |
| } | |
| if (! empty($searchSMSLogReq->status)) { | |
| $criteria .= " AND status = '$searchSMSLogReq->status'"; | |
| } | |
| if (! empty($searchSMSLogReq->statusDetails)) { | |
| $criteria .= " AND statusDetails like '%$searchSMSLogReq->statusDetails%'"; | |
| } | |
| if (! empty($searchSMSLogReq->userType) && ! empty($searchSMSLogReq->userName)) { | |
| $criteria .= " AND (case | |
| when sa.staffID is not null then sa.staffName | |
| when aa.adminID is not null then aa.adminName | |
| when ha.adminID is not null then ha.adminName | |
| when ada.adminID is not null then ada.adminName | |
| else | |
| 'SYSTEM' end) like '%$searchSMSLogReq->userName%' AND sl.createdByUserType = '$searchSMSLogReq->userType'"; | |
| } | |
| if (! empty($searchSMSLogReq->userType) && ! empty($searchSMSLogReq->userId)) { | |
| $criteria .= " AND createdBy = '$searchSMSLogReq->userId' AND sl.createdByUserType = '$searchSMSLogReq->userType'"; | |
| } | |
| if (! empty($searchSMSLogReq->sortBy)) { | |
| $sortOrder = " ORDER BY $searchSMSLogReq->sortBy $searchSMSLogReq->sortOrder"; | |
| } | |
| if (! $searchSMSLogReq->isExport ) { | |
| $limit = ' LIMIT ' . $searchSMSLogReq->startIndex . ',' . $searchSMSLogReq->endIndex; | |
| } | |
| if(!empty($searchSMSLogReq->id)) | |
| { | |
| $limit = null; | |
| } | |
| } else { | |
| $sortOrder = " ORDER BY createdDate Desc"; | |
| } | |
| $sqlCount .= $criteria; | |
| $sql .= $criteria; | |
| $sql .= $sortOrder; | |
| $sql .= $limit; | |
| $response->totalRecords = $this->executeQueryForObject($sqlCount)->totalRecords; | |
| $response->smsLogs = $this->executeQueryForList($sql,$this->mapper[SMSServiceMapper::SEARCH_SMS_LOG]); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $response; | |
| } | |
| public function createSMSLog(SMSLog $smsLog) | |
| { | |
| $smsLog = $this->realEscapeObject($smsLog); | |
| $id = null; | |
| $mobileNos = empty($smsLog->mobileNos) ? null : implode(",", $smsLog->mobileNos); | |
| $sql = "INSERT INTO `SMSLog` (`smsProviderCode`, `module`, `context`, `mobileNos`, `statusDetails`, `message`, `status`, `createdByUserType`, `createdBy`, `updatedBy`, `createdDate`, `updatedDate`, `updatedByUserType`) | |
| VALUES ('$smsLog->smsProviderCode', '$smsLog->module', '$smsLog->context', '$mobileNos', '$smsLog->statusDetails', '$smsLog->message', '$smsLog->status', '$smsLog->createdByUserType', '$smsLog->createdBy', '$smsLog->createdBy', now(), now(), '$smsLog->createdByUserType'); | |
| "; | |
| try { | |
| $id = $this->executeQueryForObject($sql, true); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $id; | |
| } | |
| /** | |
| * getSMSProviderDetails of given module | |
| * | |
| * @param string $module | |
| * @param string $category | |
| * @throws ProfessionalException | |
| * @return SMSProvider | |
| */ | |
| public function getSMSProviderDetails($module) | |
| { | |
| $module = $this->realEscapeString($module); | |
| $SMSProvider = null; | |
| $sql = "SELECT | |
| sp.id as smsProviderId,sp.code as smsProviderCode, | |
| sp.name as smsProviderName, | |
| sp.url as smsProviderUrl, | |
| spa.id as smsProviderAttrId, | |
| spa.code as smsProviderAttrCode, | |
| spa.name as smsProviderAttrName, | |
| spav.id as smsProviderAttrValueId, | |
| spav.smsProviderModuleId as smsProviderModuleId, | |
| spav.value as smsProviderAttrValue | |
| FROM SMSProviderModule spm | |
| INNER JOIN SMSProvider sp on sp.id = spm.smsProviderId | |
| INNER JOIN SMSProviderAttribute spa on spa.smsProviderId = sp.id | |
| LEFT JOIN SMSProviderAttributeValue spav on spav.smsProviderAttributeId = spa.id | |
| AND spav.smsProviderModuleId = spm.id | |
| WHERE spm.module = '$module'; | |
| "; | |
| try { | |
| $isNothing = $this->executeQueryForObject($sql); | |
| if(!$isNothing && $module != "ALL") | |
| { | |
| $sql = "SELECT | |
| sp.id as smsProviderId,sp.code as smsProviderCode, | |
| sp.name as smsProviderName, | |
| sp.url as smsProviderUrl, | |
| spa.id as smsProviderAttrId, | |
| spa.code as smsProviderAttrCode, | |
| spa.name as smsProviderAttrName, | |
| spav.id as smsProviderAttrValueId, | |
| spav.smsProviderModuleId as smsProviderModuleId, | |
| spav.value as smsProviderAttrValue | |
| FROM SMSProviderModule spm | |
| INNER JOIN SMSProvider sp on sp.id = spm.smsProviderId | |
| INNER JOIN SMSProviderAttribute spa on spa.smsProviderId = sp.id | |
| LEFT JOIN SMSProviderAttributeValue spav on spav.smsProviderAttributeId = spa.id | |
| AND spav.smsProviderModuleId = spm.id | |
| WHERE spm.module = 'ALL'"; | |
| } | |
| $SMSProvider = $this->executeQueryForObject($sql, false, $this->mapper[SMSServiceMapper::GET_SMS_PROVIDER_DETAILS]); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $SMSProvider; | |
| } | |
| /** | |
| * getSMSProviderDetailsByModuleId of given module id | |
| * | |
| * @param string $module | |
| * @param string $category | |
| * @throws ProfessionalException | |
| * @return SMSProvider | |
| */ | |
| public function getSMSProviderDetailsByModuleId($moduleId) | |
| { | |
| $moduleId = $this->realEscapeString($moduleId); | |
| $sql = "SELECT | |
| sp.id as smsProviderId,sp.code as smsProviderCode, | |
| sp.name as smsProviderName, | |
| sp.url as smsProviderUrl, | |
| spa.id as smsProviderAttrId, | |
| spa.code as smsProviderAttrCode, | |
| spa.name as smsProviderAttrName, | |
| spav.id as smsProviderAttrValueId, | |
| spav.smsProviderModuleId as smsProviderModuleId, | |
| spav.value as smsProviderAttrValue | |
| FROM SMSProviderModule spm | |
| INNER JOIN SMSProvider sp on sp.id = spm.paymentGatewayId | |
| INNER JOIN SMSProviderAttribute spa on spa.paymentGatewayid = sp.id | |
| LEFT JOIN SMSProviderAttributeValue spav on spav.paymentGatewayAttrId = spa.id | |
| AND spav.paymentGatewayModuleId = spm.id | |
| WHERE spm.id = $moduleId; | |
| "; | |
| try { | |
| $SMSProvider = $this->executeQueryForObject($sql, false, $this->mapper[SMSServiceMapper::GET_SMS_PROVIDER_DETAILS]); | |
| } catch (\Exception $e) { | |
| throw new ProfessionalException($e->getCode(), $e->getMessage()); | |
| } | |
| return $SMSProvider; | |
| } | |
| /** | |
| * get sms provider attribute value from attributelist | |
| * | |
| * @param string $attributeCode | |
| * @param string $attributesList | |
| * @return NULL | |
| */ | |
| public function getSMSProviderAttributeValue($attributeCode, $attributesList) | |
| { | |
| $attributesList = (Array)$attributesList; | |
| $attrValue = null; | |
| if (! count($attributesList)== 0 && ! empty($attributeCode)) { | |
| foreach ($attributesList as $attr) { | |
| if ($attr->code == $attributeCode) { | |
| $attrValue = empty($attr->smsProviderAttributeValue) ? null : $attr->smsProviderAttributeValue->value; | |
| break; | |
| } | |
| } | |
| } | |
| return $attrValue; | |
| } | |
| private function parseAPIResponse($apiResponse) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if (! empty($apiResponse->body->error_code)) { | |
| if ($apiResponse->body->error_code == 0) { | |
| $smsResponse->success = true; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->errorCode = $apiResponse->body->error_code; | |
| $smsResponse->message = $apiResponse->body->error_message; | |
| } | |
| } else { | |
| $smsResponse->success = false; | |
| // $smsResponse->errorCode = $apiResponse->body->error_code; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| return $smsResponse; | |
| } | |
| private function processCreatelogSMS($sms, $smsProviderCode, $module, $status, $statusDetails) | |
| { | |
| $smsLog = new SMSLog(); | |
| if (! empty($sms)) { | |
| $smsLog->context = $sms->context; | |
| $smsLog->createdBy = $sms->createdBy; | |
| $smsLog->createdByUserType = $sms->createdByUserType; | |
| $smsLog->message = $sms->message; | |
| $smsLog->mobileNos = $sms->mobileNos; | |
| $smsLog->updatedBy = $sms->updatedBy; | |
| $smsLog->updatedByUserType = $sms->updatedByUserType; | |
| } | |
| $smsLog->smsProviderCode = $smsProviderCode; | |
| $smsLog->module = $module; | |
| $smsLog->statusDetails = is_object($statusDetails) ? json_encode($statusDetails) : $statusDetails; | |
| $smsLog->status = $status; | |
| return $this->createSMSLog($smsLog); | |
| } | |
| /** | |
| * Method for sending sms | |
| * | |
| * @param SMS $sms,SMSProvider | |
| * $smsProvider | |
| */ | |
| public function sendSMS($sms,$templateId= null) | |
| { | |
| $smsResponse = null; | |
| // $apiResponse = null; | |
| // Validate SMS Request | |
| $this->validateSMSRequest($sms); | |
| $smsProviderCode = null; | |
| try { | |
| $smsProvider = $this->getSMSProviderDetails($sms->module); | |
| if ($smsProvider) { | |
| $smsProviderCode = $smsProvider->code; | |
| switch ($smsProviderCode) { | |
| case SMSProvider::XPRESSSMS: | |
| $smsResponse = $this->sendSMSViaXPRESSSMS($sms, $smsProvider,$templateId); | |
| break; | |
| // TO DO | |
| // case "GLOZNET": | |
| // $smsResponse = $this->sendSMSViaGLOZNET($sms, $smsProvider); | |
| // break; | |
| case SMSProvider::TECHSOL: | |
| $smsResponse = $this->sendSMSViaTECHSOL($sms, $smsProvider); | |
| break; | |
| case SMSProvider::BHASHSMS: | |
| $smsResponse = $this->sendSMSViaBHASHSMS($sms, $smsProvider); | |
| break; | |
| case SMSProvider::ZORZACORP: | |
| $smsResponse = $this->sendSMSViaZORZACORP($sms, $smsProvider); | |
| break; | |
| case SMSProvider::MITHRA: | |
| $smsResponse = $this->sendSMSViaMithra($sms, $smsProvider); | |
| break; | |
| case SMSProvider::BULK_SMS: | |
| $smsResponse = $this->sendSMSViaBULKSMS($sms, $smsProvider); | |
| break; | |
| case SMSProvider::SCHOOL_SERVE_SMS: | |
| $smsResponse = $this->sendSMSViaSCHOOLSERVESMSV1_3($sms, $smsProvider); | |
| break; | |
| case SMSProvider::MY_SMS_MANTRA: | |
| $smsResponse = $this->sendSMSViaMYSMSMANTRA($sms, $smsProvider); | |
| break; | |
| case SMSProvider::MOB_TEXTING: | |
| $smsResponse = $this->sendSMSViaMOBTEXTING($sms, $smsProvider); | |
| break; | |
| case SMSProvider::SMS_GUPSHUP: | |
| $smsResponse = $this->sendSMSViaSMSGUPSHUP($sms, $smsProvider); | |
| break; | |
| case SMSProvider::SMS_COUNTRY: | |
| $smsResponse = $this->sendSMSViaSMSCOUNTRY($sms, $smsProvider); | |
| break; | |
| case SMSProvider::SMS_AVEON: | |
| $smsResponse = $this->sendSMSViaSMSAVEON($sms, $smsProvider); | |
| break; | |
| case SMSProvider::BULK_SMS_GREEN_ADS: | |
| $smsResponse = $this->sendSMSViaBULKSMSGREENADS($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::AASTHA: | |
| $smsResponse = $this->sendSMSViaAastha($sms, $smsProvider); | |
| break; | |
| case SMSProvider::AVENTSMS: | |
| $smsResponse = $this->sendSMSViaAventsms($sms, $smsProvider); | |
| break; | |
| case SMSProvider::RITSGATEWAY: | |
| $smsResponse = $this->sendSMSViaRitsGateway($sms, $smsProvider); | |
| break; | |
| case SMSProvider::FASTSMS: | |
| $smsResponse = $this->sendSMSViaFastSMS($sms, $smsProvider); | |
| break; | |
| case SMSProvider::SAPTELESERVICES: | |
| $smsResponse = $this->sendSMSViaSAPTELESERVICES($sms, $smsProvider); | |
| break; | |
| case SMSProvider::HINDUSTANSOFT: | |
| $smsResponse = $this->sendSMSViaHindustanSoft($sms, $smsProvider); | |
| break; | |
| case SMSProvider::BLESSSMS: | |
| $smsResponse = $this->sendSMSViaBlessSMS($sms, $smsProvider); | |
| break; | |
| case SMSProvider::MOPLET: | |
| $smsResponse = $this->sendSMSViaMoplet($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::REFINED_SMS: | |
| $smsResponse = $this->sendSMSViaRefined($sms, $smsProvider); | |
| break; | |
| case SMSProvider::PRPSMS: | |
| $smsResponse = $this->sendSMSViaPRPSMS($sms, $smsProvider); | |
| break; | |
| case SMSProvider::MERABT: | |
| $smsResponse = $this->sendSMSViaMERABT($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::SUPERSMSIDEA: | |
| $smsResponse = $this->sendSMSViaSuperSMSIdea($sms, $smsProvider); | |
| break; | |
| case SMSProvider::RUBYSOFT: | |
| $smsResponse = $this->sendSMSViaRubySoft($sms, $smsProvider); | |
| break; | |
| case SMSProvider::SMSSERVER: | |
| $smsResponse = $this->sendSMSViaSMSServer($sms, $smsProvider); | |
| break; | |
| case SMSProvider::BSNL: | |
| $smsResponse = $this->sendSMSViaBsnlServer($sms, $smsProvider); | |
| break; | |
| case SMSProvider::MDSMEDIA: | |
| $smsResponse = $this->sendSMSViaMdsMedia($sms, $smsProvider); | |
| break; | |
| case SMSProvider::SMSU: | |
| $smsResponse = $this->sendSMSViaSmsu($sms, $smsProvider); | |
| break; | |
| case SMSProvider::EXTREMAA: | |
| $smsResponse = $this->sendSMSViaExtremaa($sms, $smsProvider); | |
| break; | |
| case SMSProvider::THE_PARENT_ALERT: | |
| $smsResponse = $this->sendSMSViaTheParentAlert($sms, $smsProvider); | |
| break; | |
| case SMSProvider::KALEYRA: | |
| $smsResponse = $this->sendSMSViaKalerya($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::ROUNDSMS: | |
| $smsResponse = $this->sendSMSViaRoundSms($sms, $smsProvider); | |
| break; | |
| case SMSProvider::BULKSMSCOCHIN: | |
| $smsResponse = $this->sendSMSViaBulkSmsCochin($sms, $smsProvider); | |
| break; | |
| case SMSProvider::FIRSTDIAL: | |
| $smsResponse = $this->sendSMSFirstDial($sms, $smsProvider); | |
| break; | |
| case SMSProvider::ALERT: | |
| $smsResponse = $this->sendSMSAlert($sms, $smsProvider); | |
| break; | |
| case SMSProvider::SAC: | |
| $smsResponse = $this->sendSMSSAC($sms, $smsProvider); | |
| break; | |
| case SMSProvider::SAGARHOSTING: | |
| $smsResponse = $this->sendSMSViaSagarHosting($sms, $smsProvider); | |
| break; | |
| case SMSProvider::MTALKS: | |
| $smsResponse = $this->sendSMSViaMTALKS($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::SKYPIXELS: | |
| $smsResponse = $this->sendSMSViaSKYPIXELS($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::ICECUBE: | |
| $smsResponse = $this->sendSMSViaICECUBE($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::TXTLOCAL: | |
| $smsResponse = $this->sendSMSViaTXTLOCAL($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::SANGAMAM: | |
| $smsResponse = $this->sendSMSSANGAMAM($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::MSG91: | |
| $smsResponse = $this->sendSMSMsg91($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::GETLEAD: | |
| $smsResponse = $this->use_getleadSMS($sms, $smsProvider); | |
| break; | |
| case SMSProvider::SMSBITS: | |
| $smsResponse = $this->use_getSMSBITS($sms, $smsProvider, $templateId); | |
| break; | |
| case SMSProvider::SMSAASTHA: | |
| $smsResponse = $this->use_getSMSAASTHA($sms, $smsProvider); | |
| break; | |
| case SMSProvider::DATAGENIT: | |
| $smsResponse = $this->use_getDATAGENIT($sms, $smsProvider); | |
| break; | |
| case SMSProvider::INSTAALERTS: | |
| $smsResponse = $this->sendSMSViaINSTAALERT($sms, $smsProvider, $templateId); | |
| break; | |
| case SMSProvider::ADLINKS: | |
| $smsResponse = $this->sendSMSViaADLINKS($sms, $smsProvider, $templateId); | |
| break; | |
| case SMSProvider::CLARET_CLG: | |
| $smsResponse = $this->sendSMSViaCLARETCLG($sms, $smsProvider, $templateId); | |
| break; | |
| case SMSProvider::MY_SMS_BASKET: | |
| $smsResponse = $this->sendSMSViaMySmsBasket($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::EASYWAYSMS: | |
| $smsResponse = $this->sendSMSViaEASYWAYSMS($sms, $smsProvider,$templateId); | |
| break; | |
| case SMSProvider::MDSSEND: | |
| $smsResponse = $this->sendSMSViaMdsSend($sms, $smsProvider, $templateId); | |
| break; | |
| default: | |
| throw new SMSException(SMSException::SMS_PROVIDER_NOT_INTEGRATED, "SMS Provider is not integrated '$smsProvider->code"); | |
| ; | |
| break; | |
| } | |
| } else { | |
| throw new SMSException(SMSException::SMS_PROVIDER_NOT_FOUND, "SMS Provider not configured or no SMS provider found for the module '$sms->module'"); | |
| } | |
| } catch (\Exception $e) { | |
| if ($e->getCode() == SMSException::SMS_PROVIDER_NOT_INTEGRATED) { | |
| $this->processCreatelogSMS($sms, $smsProviderCode, $sms->module, SMS::STATUS_FAILED, "SMS Provider is not integrated '$smsProvider->code"); | |
| } else if ($e->getCode() == SMSException::SMS_PROVIDER_NOT_FOUND) { | |
| $this->processCreatelogSMS($sms, $smsProviderCode, $sms->module, SMS::STATUS_FAILED, "SMS Provider not configured or no SMS provider found for module '$sms->module'"); | |
| } else { | |
| $this->processCreatelogSMS($sms, $smsProviderCode, $sms->module, SMS::STATUS_FAILED, $e->getMessage()); | |
| } | |
| throw $e; | |
| } | |
| // Log sms | |
| $this->processCreatelogSMS($sms, $smsProviderCode, $sms->module, ($smsResponse->success ? SMS::STATUS_SUCCESS : SMS::STATUS_FAILED), $smsResponse->message); | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaRitsGateway($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('UNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PWD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'uname=' . $SMS_USERNAME; | |
| $SMS_URL .= '&pwd=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&senderid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&msg=' . $msg; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaXPRESSSMS($sms, $smsProvider,$templateId) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_API_PASSWORD = $this->getSMSProviderAttributeValue('API_PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_ACTION = $this->getSMSProviderAttributeValue('ACTION', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_API_VERSION = $this->getSMSProviderAttributeValue('API_VERSION', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_OTP_VALUE = $this->getSMSProviderAttributeValue('ROUTE_OTP_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_PRINCIPLE_ENTITY_ID = $this->getSMSProviderAttributeValue('PRINCIPLE_ENTITY_ID', $smsProvider->smsProviderAttributes); | |
| // Set message type. | |
| //$SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| switch ($sms->route) { | |
| case SMS::ROUTE_PROMOTIONAL: | |
| $SMS_ROUTE = $SMS_ROUTE_PROMOTIONAL_VALUE; | |
| break; | |
| case SMS::ROUTE_TRANSACTIONAL: | |
| $SMS_ROUTE = $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| break; | |
| case SMS::ROUTE_OTP: | |
| $SMS_ROUTE = $SMS_ROUTE_OTP_VALUE; | |
| break; | |
| default : | |
| $SMS_ROUTE = $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| break; | |
| } | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| if(is_array($sms->mobileNos)){ | |
| array_walk($sms->mobileNos, function (&$mobileNo) { | |
| $mobileNo = strval($mobileNo); | |
| if (substr($mobileNo, 0, 1) === '0') { | |
| $mobileNo = substr($mobileNo, 1); | |
| } | |
| if (strlen($mobileNo) == 10) { | |
| $mobileNo = "91" . $mobileNo; | |
| } | |
| elseif(substr($mobileNo, 0, 1) === '+'){ | |
| $mobileNo = substr($mobileNo, 1); | |
| } | |
| }); | |
| $phonNo = implode(",",$sms->mobileNos); | |
| } | |
| else{ | |
| $sms->mobileNos = strval($sms->mobileNos); | |
| if (substr($sms->mobileNos, 0, 1) === '0') { | |
| $sms->mobileNos = substr($sms->mobileNos, 1); | |
| } | |
| if (strlen($sms->mobileNos) == 10) { | |
| $sms->mobileNos = "91" . $sms->mobileNos; | |
| } | |
| else if(substr($sms->mobileNos, 0, 1) === '+'){ | |
| $sms->mobileNos = substr($sms->mobileNos, 1); | |
| } | |
| $phonNo = $sms->mobileNos; | |
| } | |
| // construct url | |
| $SMS_URL .= 'ApiKey=' . $SMS_API_PASSWORD; | |
| $SMS_URL .= '&ClientId=' . $SMS_USERNAME; | |
| $SMS_URL .= '&SenderId=' . $SMS_SENDERID; | |
| $SMS_URL .= '&Message=' . urlencode($sms->message); | |
| $SMS_URL .= '&MobileNumbers=' . $phonNo; | |
| $SMS_URL .= '&principleEntityId='.$SMS_PRINCIPLE_ENTITY_ID; | |
| if($templateId){ | |
| $SMS_URL .= '&templateId='.$templateId; | |
| } | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaGLOZNET($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // construct url | |
| $SMS_URL .= 'authkey=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&mobiles=' . $phonNo; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| $smsResponse->message = $apiResponse->body; | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaTECHSOL($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // construct url | |
| $SMS_URL .= 'workingkey=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| try { | |
| // Message GID=9349135992 ID=9349135992-1 | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaBHASHSMS($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $phonNo = null; | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_API_PASSWORD = $this->getSMSProviderAttributeValue('API_PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // API Won't send sms with starting 91 so we need to remove 91 from starting of mobile no. | |
| foreach ($sms->mobileNos as $key => $value) { | |
| if (preg_match("/^91[0-9]{10}$/", $value)) { | |
| $sms->mobileNos[$key] = substr($value, 2); | |
| } | |
| } | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // construct url | |
| $SMS_URL .= 'user=' . $SMS_USERNAME; | |
| $SMS_URL .= '&pass=' . $SMS_API_PASSWORD; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&phone=' . $phonNo; | |
| $SMS_URL .= '&text=' . urlencode($sms->message); | |
| $SMS_URL .= '&priority=ndnd&stype=normal'; | |
| try { | |
| // Message GID=9349135992 ID=9349135992-1 | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaZORZACORP($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'token=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&number=' . $phonNo; | |
| $SMS_URL .= '&sms=' . urlencode($sms->message); | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&type=' . $SMS_MESSAGE_TYPE; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaMithra($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'token=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&number=' . $phonNo; | |
| $SMS_URL .= '&sms=' . urlencode($sms->message); | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&type=' . $SMS_MESSAGE_TYPE; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaBULKSMS($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $postData = array( | |
| 'authkey' => $SMS_AUTHKEY, | |
| 'mobiles' => $phonNo, | |
| 'message' => urlencode($sms->message), | |
| 'sender' => $SMS_SENDERID, | |
| 'route' => $SMS_ROUTE | |
| ); | |
| try { | |
| $ch = curl_init(); | |
| curl_setopt_array($ch, array( | |
| CURLOPT_URL => $SMS_URL, | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_POST => true, | |
| CURLOPT_POSTFIELDS => $postData | |
| )); | |
| // ignore SSL certificate verification | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
| // Get Response | |
| $apiResponse = curl_exec($ch); | |
| $apiResponse = json_decode($apiResponse); | |
| $info = curl_getinfo($ch); | |
| // $apiResponse = $this->callSendSMSAPIPost($SMS_URL,$postData); | |
| if (! empty($apiResponse)) { | |
| if ($info['http_code'] == 200) { | |
| if (strpos($apiResponse->type, 'error') !== false) { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->message; | |
| } else { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->message; | |
| } | |
| } else { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse; | |
| } | |
| } | |
| curl_close($ch); | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| /** | |
| * | |
| * @deprecated MEthod for sending sms via schoolserve sms provider | |
| * @param SMS $sms | |
| * @param SMSProvider $smsProvider | |
| * @throws SMSException | |
| * @return \com\linways\base\dto\sms\SMSResponse | |
| */ | |
| public function sendSMSViaSCHOOLSERVESMS($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_API_UID = $this->getSMSProviderAttributeValue('UID', $smsProvider->smsProviderAttributes); | |
| $SMS_API_PIN = $this->getSMSProviderAttributeValue('PIN', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_TEMPID = $this->getSMSProviderAttributeValue('TEMPID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $postData = array( | |
| 'uid' => $SMS_API_UID, | |
| 'pin' => $SMS_API_PIN, | |
| 'sender' => $SMS_SENDERID, | |
| 'route' => $SMS_ROUTE, | |
| 'mobile' => $phonNo, | |
| 'message' => $sms->message, | |
| 'tempid' => $SMS_TEMPID | |
| ); | |
| try { | |
| $ch = curl_init(); | |
| curl_setopt_array($ch, array( | |
| CURLOPT_URL => $SMS_URL, | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_POST => true, | |
| CURLOPT_POSTFIELDS => $postData | |
| )); | |
| // ignore SSL certificate verification | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
| // Get Response | |
| $apiResponse = curl_exec($ch); | |
| // $apiResponse = json_decode($apiResponse); | |
| $info = curl_getinfo($ch); | |
| // // Print error if any | |
| if (curl_errno($ch)) { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse; | |
| } else { | |
| $errorDetails = json_decode($apiResponse); | |
| if ($info['http_code'] == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = ($errorDetails == null ? ($apiResponse) : $errorDetails->message); | |
| } | |
| } | |
| curl_close($ch); | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| /** | |
| * | |
| * MEthod for sending sms via schoolserve sms provider by using api version 1.3 | |
| * | |
| * @param SMS $sms | |
| * @param SMSProvider $smsProvider | |
| * @throws SMSException | |
| * @return \com\linways\base\dto\sms\SMSResponse | |
| */ | |
| public function sendSMSViaSCHOOLSERVESMSV1_3($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_APIKEY = $this->getSMSProviderAttributeValue('API_KEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '3' : '1'; | |
| // http://yourdomain.com/webservice/smsSimpleApi.php?usersName=USERNAME | |
| // &key=APIKEY&route=2&message=MESSAGE&numbers=95XXXXXXXX&senderId=SEND | |
| // ERID | |
| // construct url | |
| $SMS_URL .= 'usersName=' . $SMS_USERNAME; | |
| $SMS_URL .= '&key=' . $SMS_APIKEY; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| $SMS_URL .= '&numbers=' . $phonNo; | |
| $SMS_URL .= '&senderId=' . $SMS_SENDERID; | |
| $SMS_URL .= '&smsType=' . $SMS_MESSAGE_TYPE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaMYSMSMANTRA($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_API_PASSWORD = $this->getSMSProviderAttributeValue('API_PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // construct url | |
| $SMS_URL .= 'username=' . $SMS_USERNAME; | |
| $SMS_URL .= '&password=' . $SMS_API_PASSWORD; | |
| $SMS_URL .= '&sendername=' . $SMS_SENDERID; | |
| $SMS_URL .= '&mobileno=' . $phonNo; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaSMSGUPSHUP($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_METHOD = $this->getSMSProviderAttributeValue('METHOD', $smsProvider->smsProviderAttributes); | |
| $SMS_USERID = $this->getSMSProviderAttributeValue('USERID', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_API_VERSION = $this->getSMSProviderAttributeValue('API_VERSION', $smsProvider->smsProviderAttributes); | |
| $SMS_MSG_TYPE = $this->getSMSProviderAttributeValue('MSG_TYPE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $postData = array( | |
| 'method' => $SMS_METHOD, | |
| 'send_to' => $phonNo, | |
| 'msg' => urlencode($sms->message), | |
| 'userid' => $SMS_USERID, | |
| 'password' => $SMS_PASSWORD, | |
| 'v' => $SMS_API_VERSION, | |
| 'msg_type' => $SMS_MSG_TYPE, | |
| 'auth_scheme' => "PLAIN" | |
| ); | |
| try { | |
| $ch = curl_init(); | |
| curl_setopt_array($ch, array( | |
| CURLOPT_URL => $SMS_URL, | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_POST => true, | |
| CURLOPT_POSTFIELDS => $postData | |
| )); | |
| // ignore SSL certificate verification | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
| // Get Response | |
| $apiResponse = curl_exec($ch); | |
| $info = curl_getinfo($ch); | |
| if (curl_errno($ch)) { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse; | |
| } else { | |
| if ($info['http_code'] == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse; | |
| } else { | |
| $smsResponse->message = $apiResponse; | |
| $smsResponse->success = false; | |
| } | |
| } | |
| curl_close($ch); | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaMOBTEXTING($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_API_KEY = $this->getSMSProviderAttributeValue('API_KEY', $smsProvider->smsProviderAttributes); | |
| $SMS_METHOD = $this->getSMSProviderAttributeValue('METHOD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // construct url | |
| $SMS_URL .= 'method=' . $SMS_METHOD; | |
| $SMS_URL .= '&api_key=' . $SMS_API_KEY; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body->data->message; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body->data->message; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaSMSCOUNTRY($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERID = $this->getSMSProviderAttributeValue('USERID', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_MSG_TYPE = $this->getSMSProviderAttributeValue('MSG_TYPE', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $postData = array( | |
| 'User' => $SMS_USERID, | |
| 'passwd' => $SMS_PASSWORD, | |
| 'mobilenumber' => $phonNo, | |
| 'message' => urlencode($sms->message), | |
| 'sid' => $SMS_SENDERID, | |
| 'mtype' => $SMS_MSG_TYPE, | |
| 'DR' => 'Y' | |
| ); | |
| try { | |
| $ch = curl_init(); | |
| curl_setopt_array($ch, array( | |
| CURLOPT_URL => $SMS_URL, | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_POST => true, | |
| CURLOPT_POSTFIELDS => $postData | |
| )); | |
| // ignore SSL certificate verification | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
| curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
| // Get Response | |
| $apiResponse = curl_exec($ch); | |
| $info = curl_getinfo($ch); | |
| if (curl_errno($ch)) { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse; | |
| } else { | |
| if ($info['http_code'] == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse; | |
| } | |
| } | |
| curl_close($ch); | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaSMSAVEON($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_CONTENT_TYPE = $this->getSMSProviderAttributeValue('CONTENT_TYPE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // construct url | |
| $SMS_URL .= 'AUTH_KEY=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| $SMS_URL .= '&senderId=' . $SMS_SENDERID; | |
| $SMS_URL .= '&routeId=' . $SMS_ROUTE; | |
| $SMS_URL .= '&mobileNos=' . $phonNo; | |
| $SMS_URL .= '&smsContentType=' . $SMS_CONTENT_TYPE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body->response; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body->response; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaAastha($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| $curl = curl_init(); | |
| $urlWithFormat = $SMS_URL . "format/json"; | |
| // Send the POST request with cURL | |
| curl_setopt_array($curl, array( | |
| CURLOPT_RETURNTRANSFER => 1, | |
| CURLOPT_URL => $urlWithFormat, | |
| CURLOPT_POST => 1, | |
| CURLOPT_CUSTOMREQUEST => 'POST', | |
| CURLOPT_HTTPHEADER => array( | |
| "X-Authentication-Key:$SMS_AUTHKEY", | |
| 'X-Api-Method:MT' | |
| ), | |
| CURLOPT_POSTFIELDS => array( | |
| 'mobile' => $phonNo, | |
| 'route' => $SMS_ROUTE, | |
| 'text' => $msg, | |
| 'sender' => $SMS_SENDERID | |
| ) | |
| )); | |
| // Send the request & save response to $response | |
| $response = curl_exec($curl); | |
| $info = curl_getinfo($curl); | |
| // Print error if any | |
| if (curl_errno($curl)) { | |
| $smsResponse->success = false; | |
| $smsResponse->message = curl_error($curl); | |
| } else { | |
| $errorDetails = json_decode($response); | |
| if ($info['http_code'] == 200) { | |
| $smsResponse->success = true; | |
| $response; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $response; | |
| } | |
| } | |
| // Close request to clear up some resources | |
| curl_close($curl); | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaAventsms($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'username=' . $SMS_USERNAME; | |
| $SMS_URL .= '&password=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&message=' . $msg; | |
| $SMS_URL .= '&reqid=1&format=text&route_id=760'; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaHindustanSoft($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'user=' . $SMS_USERNAME; | |
| $SMS_URL .= '&password=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&sid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&msisdn=' . $phonNo; | |
| $SMS_URL .= '&msg=' . $msg; | |
| $SMS_URL .= '&gwid=' . $SMS_ROUTE; | |
| $SMS_URL .= '&fl=0'; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body->ErrorMessage; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body->ErrorMessage; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaBULKSMSGREENADS($sms, $smsProvider, $templateId=null) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERID', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_URL .= 'username=' . $SMS_USERNAME; | |
| $SMS_URL .= '&password=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&mobile=' . $phonNo; | |
| $SMS_URL .= '&sendername=' . $SMS_SENDERID; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| $SMS_URL .= '&routetype=' . $SMS_ROUTE; | |
| if($templateId){ | |
| $SMS_URL .= '&tid='.$templateId; | |
| } | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaSAPTELESERVICES($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERID = $this->getSMSProviderAttributeValue('USERID', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| try { | |
| $ch = curl_init(); | |
| curl_setopt_array($ch, array( | |
| CURLOPT_URL => $SMS_URL, | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_ENCODING => '', | |
| CURLOPT_MAXREDIRS => 10, | |
| CURLOPT_TIMEOUT => 0, | |
| CURLOPT_FOLLOWLOCATION => true, | |
| CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | |
| CURLOPT_POST => true, | |
| CURLOPT_CUSTOMREQUEST => 'POST', | |
| CURLOPT_POSTFIELDS => "username=$SMS_USERID&password=$SMS_PASSWORD&mobile=$phonNo&sendername=$SMS_SENDERID&message=$sms->message&routetype=$SMS_ROUTE", | |
| CURLOPT_HTTPHEADER => array( | |
| 'Content-Type: application/x-www-form-urlencoded' | |
| ), | |
| )); | |
| // Get Response | |
| $apiResponse = curl_exec($ch); | |
| $info = curl_getinfo($ch); | |
| if (curl_errno($ch)) { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse; | |
| } else { | |
| if ($info['http_code'] == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse; | |
| } | |
| } | |
| curl_close($ch); | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaFastSMS($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_COUNTRY = $this->getSMSProviderAttributeValue('COUNTRY', $smsProvider->smsProviderAttributes); | |
| // $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '1' : '0'; | |
| // construct url | |
| $SMS_URL .= 'authkey=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| $SMS_URL .= '&country=' . $SMS_COUNTRY; | |
| $SMS_URL .= '&mobiles=' . $phonNo; | |
| $SMS_URL .= '&message=' . $msg; | |
| $SMS_URL .= '&unicode=' . $SMS_MESSAGE_TYPE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaBlessSMS($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $SMS_CHANNEL = $sms->route == SMS::ROUTE_PROMOTIONAL ? 'Promo' : 'Trans'; | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '8' : '0'; | |
| $msg = urlencode($sms->message); | |
| // construct url | |
| $SMS_URL .= 'user=' . $SMS_USERNAME; | |
| $SMS_URL .= '&password=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&senderid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&channel=' . $SMS_CHANNEL; | |
| $SMS_URL .= '&DCS=' . $SMS_MESSAGE_TYPE; | |
| $SMS_URL .= '&number=' . $phonNo; | |
| $SMS_URL .= '&text=' . $msg; | |
| $SMS_URL .= '&flashsms=0'; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaMoplet($sms, $smsProvider,$templateId) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_COUNTRY = $this->getSMSProviderAttributeValue('COUNTRY', $smsProvider->smsProviderAttributes); | |
| // $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '1' : '0'; | |
| // construct url | |
| $SMS_URL .= 'authkey=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| $SMS_URL .= '&country=' . $SMS_COUNTRY; | |
| $SMS_URL .= '&mobiles=' . $phonNo; | |
| $SMS_URL .= '&message=' . $msg; | |
| $SMS_URL .= '&unicode=' . $SMS_MESSAGE_TYPE; | |
| $SMS_URL .= '&DLT_TE_ID=' . $templateId; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaRefined($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '1' : '0'; | |
| // construct url | |
| $SMS_URL .= 'uname=' . urlencode($SMS_USERNAME); | |
| $SMS_URL .= '&pwd=' . urlencode($SMS_PASSWORD); | |
| $SMS_URL .= '&senderid=' . urlencode($SMS_SENDERID); | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&msg=' . $msg; | |
| $SMS_URL .= '&route=' . urlencode($SMS_ROUTE); | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaPRPSMS($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_METHOD = $this->getSMSProviderAttributeValue('METHOD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // Set message type. | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // API Won't send sms with starting 91 so we need to remove 91 from starting of mobile no. | |
| foreach ($sms->mobileNos as $key => $value) { | |
| if (preg_match("/^91[0-9]{10}$/", $value)) { | |
| $sms->mobileNos[$key] = substr($value, 2); | |
| } | |
| } | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // construct url | |
| $SMS_URL .= 'method=' . $SMS_METHOD; | |
| $SMS_URL .= '&uname=' . $SMS_USERNAME; | |
| $SMS_URL .= '&pass=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&send=' . $SMS_SENDERID; | |
| $SMS_URL .= '&dest=' . $phonNo; | |
| $SMS_URL .= '&msg=' . urlencode($sms->message); | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaMERABT($sms, $smsProvider,$templateId=null) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_APIKEY = $this->getSMSProviderAttributeValue('APIKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_METHOD = $this->getSMSProviderAttributeValue('METHOD', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_PEID = $this->getSMSProviderAttributeValue('PEID', $smsProvider->smsProviderAttributes); | |
| // API Won't send sms with starting 91 so we need to remove 91 from starting of mobile no. | |
| foreach ($sms->mobileNos as $key => $value) { | |
| if (preg_match("/^91[0-9]{10}$/", $value)) { | |
| $sms->mobileNos[$key] = substr($value, 2); | |
| } | |
| } | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '1' : '0'; | |
| // construct url | |
| try { | |
| $SMS_URL .= "format/xml"; | |
| $ch = curl_init(); | |
| // Send the POST request with cURL | |
| curl_setopt_array($ch, array( | |
| CURLOPT_RETURNTRANSFER => 1, | |
| CURLOPT_URL => $SMS_URL, | |
| CURLOPT_POST => 1, | |
| CURLOPT_CUSTOMREQUEST => 'POST', | |
| CURLOPT_HTTPHEADER => array( | |
| "X-Authentication-Key:$SMS_APIKEY", | |
| "X-Api-Method:$SMS_METHOD" | |
| ), | |
| CURLOPT_POSTFIELDS => array( | |
| 'mobile' => $phonNo, | |
| 'route' => $SMS_ROUTE, | |
| 'unicode' => $SMS_MESSAGE_TYPE, | |
| 'text' => urlencode($sms->message), | |
| 'sender' => $SMS_SENDERID, | |
| 'pe_id' => $SMS_PEID, | |
| 'pe_template_id' => $templateId | |
| ) | |
| )); | |
| $apiResponse = curl_exec($ch); | |
| if (! empty($apiResponse)) { | |
| $apiResponse = json_decode($apiResponse); | |
| if (! empty($apiResponse->error)) { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->data->message; | |
| } else { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->data->status; | |
| } | |
| } | |
| curl_close($ch); | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaSuperSMSIdea($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '3' : '1'; | |
| // construct url | |
| $SMS_URL .= 'uname=' . urlencode($SMS_USERNAME); | |
| $SMS_URL .= '&password=' . urlencode($SMS_PASSWORD); | |
| $SMS_URL .= '&sender=' . urlencode($SMS_SENDERID); | |
| $SMS_URL .= '&receiver=' . $phonNo; | |
| $SMS_URL .= '&sms=' . $msg; | |
| $SMS_URL .= '&route=' . urlencode($SMS_ROUTE); | |
| $SMS_URL .= '&msgtype=' . $SMS_MESSAGE_TYPE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaRubySoft($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_API_PASSWORD = $this->getSMSProviderAttributeValue('API_PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '1' : ''; | |
| // construct url | |
| $SMS_URL .= 'username=' . $SMS_USERNAME; | |
| $SMS_URL .= '&api_password=' . $SMS_API_PASSWORD; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&priority=' . $SMS_ROUTE; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| if (! empty($SMS_MESSAGE_TYPE)) { | |
| $SMS_URL .= '&unicode=' . $SMS_MESSAGE_TYPE; | |
| } | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaSMSServer($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| // $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '3' : '1'; | |
| // construct url | |
| $SMS_URL .= 'username=' . urlencode($SMS_USERNAME); | |
| $SMS_URL .= '&password=' . urlencode($SMS_PASSWORD); | |
| $SMS_URL .= '&from=' . urlencode($SMS_SENDERID); | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| $SMS_URL .= '&unicode=' . $SMS_MESSAGE_TYPE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaBsnlServer($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_USERCODE = $this->getSMSProviderAttributeValue('USERCODE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '3' : '1'; | |
| // construct url | |
| $SMS_URL .= 'Username=' . urlencode($SMS_USERNAME); | |
| $SMS_URL .= '&Password=' . urlencode($SMS_PASSWORD); | |
| $SMS_URL .= '&Usercode=' . urlencode($SMS_USERCODE); | |
| $SMS_URL .= '&Targets=' . $phonNo; | |
| $SMS_URL .= '&Message=' . urlencode($sms->message); | |
| $SMS_URL .= '&Origin=' . $SMS_SENDERID; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL,null,false,null); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaMdsMedia($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'username=' . urlencode($SMS_USERNAME); | |
| $SMS_URL .= '&password=' . urlencode($SMS_PASSWORD); | |
| $SMS_URL .= '&senderid=' . urlencode($SMS_SENDERID); | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| $SMS_URL .= '&number=' . $phonNo; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| $SMS_URL .= '&unicode=' . $SMS_MESSAGE_TYPE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaExtremaa($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // Set message type. | |
| // $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // construct url | |
| // $SMS_URL .= 'ver=' . $SMS_API_VERSION; | |
| $SMS_URL .= 'username=' . $SMS_USERNAME; | |
| $SMS_URL .= '&password=' . $SMS_PASSWORD; | |
| // $SMS_URL .= '&action=' . $SMS_ACTION; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| $SMS_URL .= '&mobile=' . $phonNo; | |
| $SMS_URL .= '&sendername=' . $SMS_SENDERID; | |
| $SMS_URL .= '&routetype=' . $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaSMSU($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_API_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| // $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // Set message type. | |
| // $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // construct url | |
| // $SMS_URL .= 'ver=' . $SMS_API_VERSION; | |
| $SMS_URL .= 'username=' . $SMS_USERNAME; | |
| $SMS_URL .= '&password=' . $SMS_API_PASSWORD; | |
| // $SMS_URL .= '&action=' . $SMS_ACTION; | |
| $SMS_URL .= '&text=' . urlencode($sms->message); | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&from=' . $SMS_SENDERID; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaTheParentAlert($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_METHOD = $this->getSMSProviderAttributeValue('METHOD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // Set message type. | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '1' : '0'; | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // construct url | |
| // $SMS_URL .= 'ver=' . $SMS_API_VERSION; | |
| $SMS_URL .= 'format/xml'; | |
| $SMS_URL .= '/key/' . $SMS_AUTHKEY; | |
| $SMS_URL .= '/method/' . $SMS_METHOD; | |
| $SMS_URL .= '/mobile/' . $phonNo; | |
| $SMS_URL .= '/sender/' . $SMS_SENDERID; | |
| $SMS_URL .= '/route/' . $SMS_ROUTE; | |
| $SMS_URL .= '/unicode/' . $SMS_MESSAGE_TYPE; | |
| $SMS_URL .= '/text/' . urlencode($sms->message); | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| /** | |
| * | |
| * MEthod for sending sms via kalerya sms provider | |
| * | |
| * @param SMS $sms | |
| * @param SMSProvider $smsProvider | |
| * @throws SMSException | |
| * @return \com\linways\base\dto\sms\SMSResponse | |
| */ | |
| public function sendSMSViaKalerya($sms, $smsProvider,$templateId = null) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_APIKEY = $this->getSMSProviderAttributeValue('API_KEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ENTITYID = $this->getSMSProviderAttributeValue('ENTITYID', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // Set message type. | |
| //https://api-alerts.kaleyra.com/v4/?api_key=A03e90b1236c911d12f7447d428a946bb&method=sms&message=test+sms+integration&to=9846218755&sender=REVAPU&unicode=0 | |
| // For supporting other languages need to set type as UTF-8 | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '1' : '0'; | |
| // construct url | |
| $SMS_URL .= 'api_key=' . $SMS_APIKEY; | |
| $SMS_URL .= '&method=sms'; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&entity_id=' . $SMS_ENTITYID; | |
| $SMS_URL .= '&unicode=' . $SMS_MESSAGE_TYPE; | |
| if($templateId){ | |
| $SMS_URL .= '&template_id='.$templateId; | |
| } | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| /** | |
| * | |
| * MEthod for sending sms via Round sms provider | |
| * | |
| * @param SMS $sms | |
| * @param SMSProvider $smsProvider | |
| * @throws SMSException | |
| * @return \com\linways\base\dto\sms\SMSResponse | |
| */ | |
| public function sendSMSViaRoundSms($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'authkey=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&mobiles=' . $phonNo; | |
| $SMS_URL .= '&message=' . urlencode($sms->message); | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&type=' . $SMS_MESSAGE_TYPE; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| $smsResponse->message = $apiResponse->body; | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaBulkSmsCochin($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'username=' . $SMS_USERNAME; | |
| $SMS_URL .= '&password=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&message=' . $msg; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSFirstDial($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_PEID = $this->getSMSProviderAttributeValue('PEID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'uname=' . $SMS_USERNAME; | |
| $SMS_URL .= '&pwd=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&senderid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&msg=' . $msg; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| $SMS_URL .= '&peid=' . $SMS_PEID; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSAlert($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('API_PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'workingkey=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&message=' . $msg; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSSAC($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('API_PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'AUTH_KEY=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&message=' . $msg; | |
| $SMS_URL .= '&senderId=' . $SMS_SENDERID.'&routeId=11'; | |
| $SMS_URL .= '&mobileNos=' . $phonNo.'&smsContentType=english'; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSViaSagarHosting($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_APIKEY = $this->getSMSProviderAttributeValue('API_KEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $SMS_CHANNEL = $sms->route == SMS::ROUTE_PROMOTIONAL ? 'Promo' : 'Trans'; | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '8' : '0'; | |
| $msg = urlencode($sms->message); | |
| // construct url | |
| $SMS_URL .= 'APIKey=' . $SMS_APIKEY; | |
| $SMS_URL .= '&senderid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&channel=' . $SMS_CHANNEL; | |
| $SMS_URL .= '&DCS=' . $SMS_MESSAGE_TYPE; | |
| $SMS_URL .= '&number=' . $phonNo; | |
| $SMS_URL .= '&text=' . $msg; | |
| $SMS_URL .= '&flashsms=0'; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function sendSMSViaMTALKS($sms, $smsProvider,$templateId) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_APIKEY = $this->getSMSProviderAttributeValue('API_KEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $phonNoSTR = implode(",", $sms->mobileNos); | |
| $msg = urlencode($sms->message); | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($msg) == "UTF-8") ? '2' : '1'; | |
| $SMS_URL = $SMS_URL.'apikey=' . $SMS_APIKEY; | |
| $SMS_URL .= '&message=' .$msg; | |
| $SMS_URL .= '&number=' . $phonNoSTR; | |
| $SMS_URL .= '&senderid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&unicode=' . $SMS_MESSAGE_TYPE; | |
| if($templateId){ | |
| $SMS_URL .= '&template_id='.$templateId; | |
| } | |
| $SMS_URL .="&format=json"; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function sendSMSViaSKYPIXELS($sms, $smsProvider,$templateId) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_APIKEY = $this->getSMSProviderAttributeValue('API_KEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $ENTITYID = $this->getSMSProviderAttributeValue('ENTITYID', $smsProvider->smsProviderAttributes); | |
| $phonNoSTR = implode(",", $sms->mobileNos); | |
| $msg = urlencode($sms->message); | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($msg) == "UTF-8") ? '2' : '1'; | |
| $SMS_URL = $SMS_URL . 'method=sms'; | |
| $SMS_URL .= '&api_key=' . $SMS_APIKEY; | |
| $SMS_URL .= '&message=' . urlencode ( $msg ); | |
| $SMS_URL .= '&to=' . $phonNoSTR; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&entity_id=' . $ENTITYID; | |
| $SMS_URL .= '&unicode=' . $SMS_MESSAGE_TYPE; | |
| if($templateId){ | |
| $SMS_URL .= '&template_id='.$templateId; | |
| } | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function sendSMSViaICECUBE($sms, $smsProvider,$templateId) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $API_KEY = $this->getSMSProviderAttributeValue('API_KEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_URL .= '&key=' . $API_KEY; | |
| $SMS_URL .= '&campaign=0&routeid=' . $SMS_ROUTE; | |
| $SMS_URL .= '&type=text&contacts=' . $phonNo; | |
| $SMS_URL .= '&senderid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&msg=' . urlencode($sms->message); | |
| if($templateId){ | |
| $SMS_URL .= '&template_id='.$templateId; | |
| } | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function sendSMSViaTXTLOCAL($sms, $smsProvider,$templateId) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $API_KEY = $this->getSMSProviderAttributeValue('API_KEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $data .= 'apikey=' . $API_KEY; | |
| $data .= '&numbers=' . $phonNo; | |
| $data .= '&sender=' . $SMS_SENDERID; | |
| $data .= '&message=' . urlencode($sms->message); | |
| try { | |
| //$apiResponse = $this->callSendSMSAPIGet($SMS_URL,null,true); | |
| $ch = curl_init('https://api.textlocal.in/send/?' . $data); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| $apiresponse = curl_exec($ch); | |
| curl_close($ch); | |
| $smsResponse->success = true; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| public function sendSMSSANGAMAM($sms, $smsProvider,$templateId) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('API_PASSWORD', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_PEID = $this->getSMSProviderAttributeValue('PEID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // Set message type. | |
| // For supporting other languages need to set type as UTF-8 | |
| // $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // construct url | |
| $SMS_URL .= 'uname=' . $SMS_USERNAME; | |
| $SMS_URL .= '&pwd=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&senderid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&to=' . $phonNo; | |
| $SMS_URL .= '&msg=' . $msg; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| $SMS_URL .= '&peid=' . $SMS_PEID; | |
| $SMS_URL .= '&tempid=' . $templateId; | |
| try { | |
| // $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // // TO DO Error And success handling | |
| // if (! empty($apiResponse)) { | |
| // if ($apiResponse->code == 200) { | |
| // $smsResponse->success = true; | |
| // $smsResponse->message = $apiResponse->body; | |
| // } else { | |
| // $smsResponse->success = false; | |
| // $smsResponse->message = $apiResponse->body; | |
| // } | |
| // } | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_URL, $SMS_URL); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| $apiresponse = curl_exec($ch); | |
| curl_close($ch); | |
| $smsResponse->success = true; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function sendSMSMsg91($sms, $smsProvider,$templateId){ | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| $SMS_URL .= 'authkey=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&mobiles=' . $phonNo; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| $SMS_URL .= '&message=' . urlencode ( $msg ); | |
| $SMS_URL .= '&DLT_TE_ID=' . $templateId; | |
| // Dev Mode DLT Testing | |
| // $SMS_URL .= '&dev_mode=1'; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function use_getleadSMS($sms, $smsProvider) { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('UNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // https://app.getlead.co.uk/api/pushsms ?username=your_username&token=your_token&sender=your_senderid &to=your_recipient1&message=your_message&priority=route&message_type=1 | |
| // $phonNoSTR = implode(",", $phonNo); | |
| if (is_array ( $phonNo )) { | |
| $phonNoSTR = implode ( ",", $phonNo ); | |
| } else { | |
| $phonNoSTR = $phonNo; | |
| } | |
| $SMS_URL .='username=' . $SMS_USERNAME; | |
| $SMS_URL .= '&token=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&to=' . $phonNoSTR; | |
| $SMS_URL .= '&message=' . urlencode ( $msg ); | |
| $SMS_URL .= '&priority=' . $SMS_ROUTE; | |
| $SMS_URL .= '&message_type=' . $SMS_MESSAGE_TYPE; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| } | |
| /** | |
| * uses mgcl | |
| */ | |
| function use_getSMSBITS($sms, $smsProvider, $templateId) { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $SMS_ENTITYID = $this->getSMSProviderAttributeValue('ENTITYID', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = $sms->message; | |
| $SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // $phonNoSTR = implode(",", $phonNo); | |
| if (is_array ( $phonNo )) { | |
| $phonNoSTR = implode ( ",", $phonNo ); | |
| } else { | |
| $phonNoSTR = $phonNo; | |
| } | |
| //$SMS_URL .='username=' . $SMS_USERNAME; | |
| $SMS_URL .= 'id=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&senderid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&to=' . $phonNoSTR; | |
| $SMS_URL .= '&msg=' . urlencode ( $msg ); | |
| $SMS_URL .= '&port=' . $SMS_ROUTE; | |
| $SMS_URL .= '&dltid=' . $SMS_ENTITYID; | |
| $SMS_URL .= '&tempid=' . $templateId; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function use_getSMSAASTHA($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_APIKEY = $this->getSMSProviderAttributeValue('APIKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_CLIENTID = $this->getSMSProviderAttributeValue('CLIENTID', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $msg = $sms->message; | |
| //$SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // $phonNoSTR = implode(",", $phonNo); | |
| if (is_array ( $phonNo )) | |
| { | |
| $phonNoSTR = implode ( ",", $phonNo ); | |
| } else | |
| { | |
| $phonNoSTR = $phonNo; | |
| } | |
| $SMS_URL .= 'ApiKey=' . $SMS_APIKEY; | |
| $SMS_URL .= '&ClientId=' . $SMS_CLIENTID; | |
| $SMS_URL .= '&SenderId=' . $SMS_SENDERID; | |
| $SMS_URL .= '&Message=' . urlencode ( $msg ); | |
| $SMS_URL .= '&MobileNumbers=' . $phonNoSTR; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function use_getDATAGENIT($sms, $smsProvider) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('AUTHKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $msg = $sms->message; | |
| //$SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // $phonNoSTR = implode(",", $phonNo); | |
| if (is_array ( $phonNo )) | |
| { | |
| $phonNoSTR = implode ( ",", $phonNo ); | |
| } else | |
| { | |
| $phonNoSTR = $phonNo; | |
| } | |
| $SMS_URL .= 'auth=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&msisdn=' . $phonNoSTR; | |
| $SMS_URL .= '&senderid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&message=' . urlencode ( $msg ); | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function sendSMSViaINSTAALERT($sms, $smsProvider,$templateId){ | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('APIKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ENTITYID = $this->getSMSProviderAttributeValue('ENTITYID',$smsProvider->smsProviderAttributes); | |
| // $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| $SMS_URL .= 'ver=1.0'; | |
| $SMS_URL .= '&key=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&encrpt=0'; | |
| $SMS_URL .= '&dest=' . $phonNo; | |
| $SMS_URL .= '&send=' . $SMS_SENDERID; | |
| $SMS_URL .= '&text=' . $msg; | |
| $SMS_URL .= '&dlt_entity_id='.$SMS_ENTITYID; | |
| $SMS_URL .= $templateId?'&dlt_template_id='.$templateId:""; | |
| // $SMS_URL .= '&DLT_TE_ID=' . $templateId; | |
| // Dev Mode DLT Testing | |
| // $SMS_URL .= '&dev_mode=1'; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| if (! empty($apiResponse)) { | |
| if (! empty($apiResponse->body)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function sendSMSViaADLINKS($sms, $smsProvider,$templateId){ | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('APIKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE = $this->getSMSProviderAttributeValue('ROUTE',$smsProvider->smsProviderAttributes); | |
| $SMS_COUNTRY = $this->getSMSProviderAttributeValue('COUNTRY',$smsProvider->smsProviderAttributes); | |
| // $SMS_ROUTE_TRANSACTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_TRANSACTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| // $SMS_ROUTE_PROMOTIONAL_VALUE = $this->getSMSProviderAttributeValue('ROUTE_PROMOTIONAL_VALUE', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| $SMS_URL .= '&authkey=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&mobiles=' . $phonNo; | |
| $SMS_URL .= '&message=' . $msg; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| $SMS_URL .= '&country=' . $SMS_COUNTRY; | |
| $SMS_URL .= '&DLT_TE_ID='.$templateId; | |
| $SMS_URL .= '&response=json'; | |
| try { | |
| $response = json_decode(file_get_contents($SMS_URL)); | |
| if($response) | |
| { | |
| if($response->type == "success") | |
| { | |
| $smsResponse->success = true; | |
| $smsResponse->message = 'SMS DELIVERED'; | |
| } | |
| else | |
| { | |
| $smsResponse->success = false; | |
| $smsResponse->message = 'SMS NOT DELIVERED'; | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function SendSMSViaCLARETCLG($sms, $smsProvider,$templateId){ | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USER_NAME', $smsProvider->smsProviderAttributes); | |
| $SMS_PASSWORD = $this->getSMSProviderAttributeValue('API_PASSWORD', $smsProvider->smsProviderAttributes); | |
| // $SMS_AUTHKEY = $this->getSMSProviderAttributeValue('APIKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDER_ID', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // $SMS_ROUTE = $sms->route == SMS::ROUTE_PROMOTIONAL ? $SMS_ROUTE_PROMOTIONAL_VALUE : $SMS_ROUTE_TRANSACTIONAL_VALUE; | |
| $msg = urlencode($sms->message); | |
| // $SMS_URL .= '&authkey=' . $SMS_AUTHKEY; | |
| $SMS_URL .= '&user=' . $SMS_USERNAME; | |
| $SMS_URL .= '&password=' . $SMS_PASSWORD; | |
| $SMS_URL .= '&mobile=' . $phonNo; | |
| $SMS_URL .= '&message=' . $msg; | |
| $SMS_URL .= '&sender=' . $SMS_SENDERID; | |
| $SMS_URL .= '&type=3'; //this type passing in url the default value is 3 | |
| // $SMS_URL .= '&route=' . $SMS_ROUTE; | |
| // $SMS_URL .= '&country=' . $SMS_COUNTRY; | |
| $SMS_URL .= '&template_id='.$templateId; | |
| // $SMS_URL .= '&response=json'; | |
| try { | |
| $response = json_decode(file_get_contents($SMS_URL)); | |
| if($response) | |
| { | |
| if($response->type == "success") | |
| { | |
| $smsResponse->success = true; | |
| $smsResponse->message = 'SMS DELIVERED'; | |
| } | |
| else | |
| { | |
| $smsResponse->success = false; | |
| $smsResponse->message = 'SMS NOT DELIVERED'; | |
| } | |
| } | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function sendSMSViaMySmsBasket($sms, $smsProvider, $templateId) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_APIKEY = $this->getSMSProviderAttributeValue('APIKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_PEID = $this->getSMSProviderAttributeValue('PE_ID', $smsProvider->smsProviderAttributes); | |
| // $SMS_TEMPLATEID = $this->getSMSProviderAttributeValue('TEMPLATE_ID', $smsProvider->smsProviderAttributes); | |
| $SMS_TEMPLATEID = $templateId; | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $msg = $sms->message; | |
| //$SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // $phonNoSTR = implode(",", $phonNo); | |
| if (is_array ( $phonNo )) | |
| { | |
| $phonNoSTR = implode ( ",", $phonNo ); | |
| } else | |
| { | |
| $phonNoSTR = $phonNo; | |
| } | |
| $SMS_URL .= 'apikey=' . $SMS_APIKEY; | |
| $SMS_URL .= '&senderid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&number=' . $phonNoSTR; | |
| $SMS_URL .= '&message=' . urlencode ( $msg ); | |
| $SMS_URL .= '&pe_id=' . $SMS_PEID; | |
| $SMS_URL .= '&template_id=' . $SMS_TEMPLATEID; | |
| $SMS_URL .= '&format=json'; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->status == "OK") { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| function sendSMSViaEASYWAYSMS($sms, $smsProvider, $templateId) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_APIKEY = $this->getSMSProviderAttributeValue('APIKEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_TEMPLATEID = $templateId; | |
| $phonNo = implode(",", $sms->mobileNos); | |
| $msg = $sms->message; | |
| //$SMS_MESSAGE_TYPE = (mb_detect_encoding($sms->message) == "UTF-8") ? '2' : '1'; | |
| // $phonNoSTR = implode(",", $phonNo); | |
| if (is_array ( $phonNo )) | |
| { | |
| $phonNoSTR = implode ( ",", $phonNo ); | |
| } else | |
| { | |
| $phonNoSTR = $phonNo; | |
| } | |
| $SMS_URL .= 'key=' . $SMS_APIKEY; | |
| $SMS_URL .= '&campaign=0&routeid=26&type=text'; | |
| $SMS_URL .= '&contacts=' . $phonNoSTR; | |
| $SMS_URL .= '&senderid=' . $SMS_SENDERID; | |
| $SMS_URL .= '&msg=' . urlencode ( $msg ); | |
| $SMS_URL .= '&template_id=' . $SMS_TEMPLATEID; | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->status == "OK") { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| /** | |
| * Sends an SMS using the MdsSend SMS provider. | |
| * | |
| * @param object $sms An object containing the SMS details, including the message and recipient mobile numbers. | |
| * @param object $smsProvider An object containing the SMS provider details, including URL and attributes. | |
| * @param string $templateId The template ID to be used for the SMS. | |
| * | |
| * @return SMSResponse Returns an instance of SMSResponse indicating the success or failure of the SMS sending operation. | |
| * | |
| * @throws SMSException | |
| */ | |
| public function sendSMSViaMdsSend($sms, $smsProvider, $templateId) | |
| { | |
| $smsResponse = new SMSResponse(); | |
| $SMS_URL = $smsProvider->url; | |
| $SMS_USERNAME = $this->getSMSProviderAttributeValue('USERNAME', $smsProvider->smsProviderAttributes); | |
| $SMS_APIKEY = $this->getSMSProviderAttributeValue('API_KEY', $smsProvider->smsProviderAttributes); | |
| $SMS_SENDERID = $this->getSMSProviderAttributeValue('SENDERID', $smsProvider->smsProviderAttributes); | |
| $SMS_ROUTE = $this->getSMSProviderAttributeValue('ROUTE', $smsProvider->smsProviderAttributes); | |
| $SMS_TEMPLATEID = $templateId; | |
| $SMS_PEID = $this->getSMSProviderAttributeValue('PE_ID', $smsProvider->smsProviderAttributes); | |
| $phonNo = implode(",", $sms->mobileNos); | |
| // construct url | |
| $SMS_URL .= 'username=' . urlencode($SMS_USERNAME); | |
| $SMS_URL .= '&apikey=' . urlencode($SMS_APIKEY); | |
| $SMS_URL .= '&senderid=' . urlencode($SMS_SENDERID); | |
| $SMS_URL .= '&route=' . urlencode($SMS_ROUTE); | |
| $SMS_URL .= '&mobile=' . $phonNo; | |
| $SMS_URL .= '&text=' . urlencode($sms->message); | |
| $SMS_URL .= '&TID=' . urlencode($SMS_TEMPLATEID); | |
| $SMS_URL .= '&PEID=' . urlencode($SMS_PEID); | |
| try { | |
| $apiResponse = $this->callSendSMSAPIGet($SMS_URL); | |
| // TO DO Error And success handling | |
| if (! empty($apiResponse)) { | |
| if ($apiResponse->code == 200) { | |
| $smsResponse->success = true; | |
| $smsResponse->message = $apiResponse->body; | |
| } else { | |
| $smsResponse->success = false; | |
| $smsResponse->message = $apiResponse->body; | |
| } | |
| } | |
| $smsResponse; | |
| } catch (\Exception $e) { | |
| throw new SMSException(SMSException::SMS_PROVIDER_API_EXCEPTION, $e->getMessage()); | |
| } | |
| return $smsResponse; | |
| } | |
| /** | |
| * Send POST request to a URL | |
| * | |
| * @param string $url | |
| * URL to send the POST request to | |
| * @param array $headers | |
| * additional headers to send | |
| * @param mixed $body | |
| * POST body data | |
| * @param string $username | |
| * Basic Authentication username (deprecated) | |
| * @param string $password | |
| * Basic Authentication password (deprecated) | |
| */ | |
| private function callSendSMSAPIPost($url, $postData = null, $enableSSLVerification = false) | |
| { | |
| $header = array(); | |
| $header["Content-Type"] = 'application/json'; | |
| // $postData = Body::Json($postData); | |
| Request::verifyPeer($enableSSLVerification); | |
| return Request::post($url, $header, $postData)->body; | |
| } | |
| /** | |
| * Send a GET request to a URL | |
| * | |
| * @param string $url | |
| * URL to send the GET request to | |
| * @param mixed $parameters | |
| * parameters to send in the querystring | |
| * @param string $enableSSLVerification | |
| * @param string $contentType | |
| */ | |
| private function callSendSMSAPIGet($url, $parameters = null, $enableSSLVerification = false,$contentType = 'application/json') | |
| { | |
| $apiResponse = null; | |
| $header = array(); | |
| $header["Content-Type"] = $contentType; | |
| Request::verifyPeer($enableSSLVerification); | |
| $apiResponse = Request::get($url, $header, $parameters); | |
| return $apiResponse; | |
| } | |
| private function validateSMSRequest($sms) | |
| { | |
| if (empty($sms)) { | |
| throw new SMSException(SMSException::INVALID_REQUEST, "SMS request is empty or not valid"); | |
| } | |
| if (empty($sms->context)) { | |
| throw new SMSException(SMSException::CONTEXT_EMPTY, "SMS context is empty or null"); | |
| } | |
| if (empty($sms->module)) { | |
| throw new SMSException(SMSException::MODULE_EMPTY, "SMS module is empty or null"); | |
| } | |
| if (empty($sms->mobileNos)) { | |
| throw new SMSException(SMSException::MOBILE_NO_EMPTY, "SMS mobile nos is empty or not specified"); | |
| } | |
| } | |
| } | |
| ?> |