SMS.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Libs;
  3. use DOMDocument;
  4. /**
  5. * 短信发送类
  6. */
  7. class SMS
  8. {
  9. private static $third_party_user_id = "526";
  10. private static $third_party_account = "youxi12";
  11. private static $third_party_password = "zwkj20141025";
  12. private static $third_party_send_url = "http://121.42.146.54:18888/sms.aspx?action=send";
  13. static function send($number,$content,$sign='追书云')
  14. {
  15. $ch = curl_init();
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  17. curl_setopt($ch, CURLOPT_HEADER, 0);
  18. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7");
  19. curl_setopt($ch, CURLOPT_POST, true);
  20. $post_data = "action=send&userid=".self::$third_party_user_id."&account=".self::$third_party_account."&password=".self::$third_party_password."&mobile=" . $number . "&content=【{$sign}】{$content}&sendTime=&checkcontent=0";
  21. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  22. curl_setopt($ch, CURLOPT_URL, self::$third_party_send_url);
  23. $res = curl_exec($ch);
  24. \Log::info($res);
  25. curl_close($ch);
  26. $xml = new DOMDocument();
  27. $xml->loadXML($res);
  28. $status = $xml->getElementsByTagName('returnstatus')->item(0)->nodeValue;
  29. $message = $xml->getElementsByTagName('message')->item(0)->nodeValue;
  30. $money_left = $xml->getElementsByTagName('remainpoint')->item(0)->nodeValue;
  31. $task_id = $xml->getElementsByTagName('taskID')->item(0)->nodeValue;
  32. $status = (($status=='Success')?1:0);
  33. return $status;
  34. }
  35. }