LifeCell.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. class LifeCell extends SMSServiceApi {
  3. public function __construct($smsServiceId, $smsPack = array()) {
  4. parent::__construct($smsServiceId, $smsPack);
  5. }
  6. public function getBalance() {
  7. $this->showErrorFeatureIsNotSupported();
  8. }
  9. public function getSMSQueue() {
  10. $this->showErrorFeatureIsNotSupported();
  11. }
  12. public function pushMessages() {
  13. $result = '';
  14. $apiUrl = $this->serviceGatewayAddr;
  15. $source = $this->instanceSendDog->safeEscapeString($this->serviceAlphaName);
  16. $login = $this->serviceLogin;
  17. $password = $this->servicePassword;
  18. $allSmsQueue = $this->smsMessagePack;
  19. if (!empty($allSmsQueue)) {
  20. foreach ($allSmsQueue as $io => $eachsms) {
  21. $number = str_replace('+', '', $eachsms['number']); //numbers in international format without +
  22. $params = array('http' =>
  23. array(
  24. 'method' => 'POST',
  25. 'header' => array('Authorization: Basic ' . base64_encode($login . ":" . $password), 'Content-Type:text/xml'),
  26. 'content' => '<message><service id="single" source="' . $source . '"/>
  27. <to>' . $number . '</to>
  28. <body content-type="text/plain">' . $eachsms['message'] . '</body></message>'));
  29. $ctx = stream_context_create($params);
  30. $fp = @fopen($apiUrl, 'rb', FALSE, $ctx);
  31. if ($fp) {
  32. $response = @stream_get_contents($fp);
  33. }
  34. //remove old sent message
  35. $this->instanceSendDog->getSmsQueueInstance()->deleteSms($eachsms['filename']);
  36. }
  37. }
  38. }
  39. public function checkMessagesStatuses() {
  40. log_register('Checking statuses for [' . get_class($this) . '] SMS service is not implemented');
  41. }
  42. }