人人商城

SMSUtil.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. class SMSUtil
  3. {
  4. public $gwUrl = 'http://sdkhttp.eucp.b2m.cn/sdk/SDKService?wsdl';
  5. public $serialNumber = '';
  6. public $password = '';
  7. public $sessionKey = '';
  8. public $connectTimeOut = 2;
  9. public $readTimeOut = 10;
  10. public $proxyhost = false;
  11. public $proxyport = false;
  12. public $proxyusername = false;
  13. public $proxypassword = false;
  14. public $client;
  15. public function __construct($gwUrl, $serialNumber, $password, $sessionKey, $proxy, $timeout, $response_timeout)
  16. {
  17. $this->gwUrl = $gwUrl;
  18. $this->serialNumber = $serialNumber;
  19. $this->password = $password;
  20. $this->sessionKey = $sessionKey;
  21. $this->connectTimeOut = $timeout;
  22. $this->readTimeOut = $response_timeout;
  23. $this->proxyhost = empty($proxy['proxyhost']) ? false : $proxy['proxyhost'];
  24. $this->proxyport = empty($proxy['$proxyport']) ? false : $proxy['proxyport'];
  25. $this->proxyusername = empty($proxy['proxyusername']) ? false : $proxy['proxyusername'];
  26. $this->proxypassword = empty($proxy['proxypassword']) ? false : $proxy['proxypassword'];
  27. $this->client = new SMSClient($this->gwUrl, $this->serialNumber, $this->password, $this->sessionKey, $this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword, $this->connectTimeOut, $this->readTimeOut);
  28. $this->client->setOutgoingEncoding('UTF-8');
  29. }
  30. /**
  31. * 余额查询
  32. */
  33. public function getBalance()
  34. {
  35. return $this->client->getBalance();
  36. }
  37. public function register($eName, $linkMan, $phoneNum, $mobile, $email, $fax, $address, $postcode)
  38. {
  39. return $this->client->registDetailInfo($eName, $linkMan, $phoneNum, $mobile, $email, $fax, $address, $postcode);
  40. }
  41. /**
  42. * 登录
  43. */
  44. public function login()
  45. {
  46. return $this->client->login();
  47. }
  48. /**
  49. * 注销登录
  50. */
  51. public function logout()
  52. {
  53. return $this->client->logout();
  54. }
  55. /**
  56. * 短信发送
  57. */
  58. public function send($mobile = '', $msg = '')
  59. {
  60. $this->client->sendSMS(array($mobile), $msg);
  61. return $this->chkError();
  62. }
  63. /**
  64. * 接口调用错误查看 用例
  65. */
  66. public function chkError()
  67. {
  68. $err = $this->client->getError();
  69. if ($err) {
  70. return $err;
  71. }
  72. return '';
  73. }
  74. /**
  75. * 获取版本号 用例
  76. */
  77. public function getVersion()
  78. {
  79. return $this->client->getVersion();
  80. }
  81. /**
  82. * 更新密码 用例
  83. */
  84. public function changePassword($pwd = '')
  85. {
  86. return $this->client->updatePassword($pwd);
  87. }
  88. }
  89. require_once dirname(__FILE__) . '/SMSClient.php';
  90. ?>