SmsPilot.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. class SmsPilot extends SMSServiceApi {
  3. public function __construct($smsServiceId, $smsPack = array()) {
  4. parent::__construct($smsServiceId, $smsPack);
  5. }
  6. public function getBalance() {
  7. $balance = file_get_contents($this->serviceGatewayAddr
  8. . '?balance=rur'
  9. . '&apikey=' . $this->serviceApiKey
  10. );
  11. //$result = wf_BackLink(self::URL_ME, '', true);
  12. $result = $this->instanceSendDog->getUBMsgHelperInstance()->getStyledMessage(__('Current account balance') . ': ' . $balance . ' RUR', 'info');
  13. //return $result;
  14. die(wf_modalAutoForm(__('Balance'), $result, $_POST['modalWindowId'], '', true, 'false', '700'));
  15. }
  16. public function getSMSQueue() {
  17. $this->showErrorFeatureIsNotSupported();
  18. }
  19. public function pushMessages() {
  20. $apikey = $this->serviceApiKey;
  21. $sender = $this->serviceAlphaName;
  22. $allSmsQueue = $this->smsMessagePack;
  23. if (!empty($allSmsQueue)) {
  24. foreach ($allSmsQueue as $sms) {
  25. $url = $this->serviceGatewayAddr
  26. . '?send=' . urlencode($sms['message'])
  27. . '&to=' . urlencode($sms['number'])
  28. . '&from=' . urlencode($sender)
  29. . '&apikey=' . urlencode($apikey)
  30. . '&format=json';
  31. $ch = curl_init($url);
  32. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
  33. curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  34. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  35. $json = curl_exec($ch);
  36. curl_close($ch);
  37. $j = json_decode($json);
  38. if ($j && isset($j->error)) {
  39. trigger_error($j->description_ru, E_USER_WARNING);
  40. }
  41. //remove old sent message
  42. $this->instanceSendDog->getSmsQueueInstance()->deleteSms($sms['filename']);
  43. }
  44. }
  45. }
  46. public function checkMessagesStatuses() {
  47. log_register('Checking statuses for [' . get_class($this) . '] SMS service is not implemented');
  48. }
  49. }
  50. ?>