Home  >  Article  >  Backend Development  >  php SMS interface

php SMS interface

WBOY
WBOYOriginal
2016-07-25 09:08:321685browse

Applicable industries: finance, industry and commerce, taxation, electricity, trade, commerce, tourism, government, postal service, education and other industries

Applicable types: connected to various B/S systems, used as various office systems, ERP, CRM, Plug-ins for e-commerce platforms (such as group text message meeting notifications, member/customer relationship communication, order generation notifications, shipping notifications, schedule reminders, reminder notifications, etc.)

Features: Green text messages, legal and formal channels, sending and receiving across the entire network
Supports text messages from China Mobile, China Unicom, China Telecom, and China Netcom, two-way interaction, and can reply to high-speed group messages

Free account application (please indicate that you are from "Shangmai Unlimited SMS Interface", 50 text messages will be given as a gift, please contact me if the test text messages are not enough)

* SMS interface file:

/*--------------------------------
Function: Unlimited business connections PHP HTTP interface to send SMS
Modification date: 2011-04-08
Description: http://http.smsdk.com/tx/?uid=user account&pwd=MD5-digit 32-digit password&mobile=number&content=content
Status:
100 Sent successfully
101 Verification failed
102 Insufficient text messages
103 Operation failed
104 Illegal characters
105 Too much content
106 Too many numbers
107 Frequency too fast
108 Number content is empty
109 Account frozen
110 Frequent single sending is prohibited
111 The system is tentatively sending
112 The number is incorrect
120 System upgrade
--------------------------------*/
$uid = '9999'; //User account
$pwd = '9999'; //Password
$mobile = '13912341234,13312341234,13512341234,02122334444'; //Number
$content = 'Shangmai Wuxian PHP HTTP interface '; //Content
//Send immediately
$res = sendSMS($uid,$pwd,$mobile,$content);
echo $res;

//Send regularly
/*
$time = '2010-05-27 12:11';
$res = sendSMS($uid,$pwd,$mobile,$content,$time);
echo $res ;
*/
function sendSMS($uid,$pwd,$mobile,$content,$time='',$mid='')
{
$http = 'http://http.c123.com/tx /';
$data = array
(
'uid'=>$uid, //User account
'pwd'=>strtolower(md5($pwd)), //MD5-digit 32 password
'mobile'=> $mobile, //Number
'content'=>$content, //Content
'time'=>$time, //Send regularly
'mid'=>$mid //Sub extension number
);
$re = postSMS($http,$data); //POST submission
if( trim($re) == '100' )
{
return "Send successfully!";
}
else
{
return "Send failed ! Status: ".$re;
}
}

function postSMS($url,$data='')
{
$row = parse_url($url);
$host = $row['host'];
$port = $row['port'] ? $row['port']:80;
$file = $row['path'];
while (list($k,$v) = each($data))
{
$post .= rawurlencode($ k)."=".rawurlencode($v)."&"; //Convert to URL standard code
}
$post = substr( $post , 0 , -1 );
$len = strlen($post);
$fp = @fsockopen( $host ,$port, $errno, $errstr, 10);
if (!$fp) {
return "$errstr ($errno)n";
} else {
$receive = '';
$out = "POST $file HTTP/1.1rn";
$out .= "Host: $hostrn";
$out .= "Content-type: application/x-www-form-urlencodedrn";
$out .= "Connection: Closern";
$out .= "Content-Length: $lenrnrn";
$out .= $post;
fwrite($fp, $out);
while (!feof($ fp)) {
$receive .= fgets($fp, 128);
}
fclose($fp);
$receive = explode("rnrn",$receive);
unset($receive[0]);
return implode("",$receive);
}
}
?>
Detailed introduction: http://www.smsdk.com/a/gb2312/news/20111205/117.html

  1. * SMS interface file:
  2. /*--------------------------------
  3. Function : Shangmai Wuxian PHP HTTP interface to send text messages
  4. Modification date: 2011-04-08
  5. Instructions: http://http.smsdk.com/tx/?uid=user account&pwd=MD5-digit 32-digit password&mobile=number&content=content
  6. Status:
  7. 100 Successfully sent
  8. 101 Verification failed
  9. 102 Insufficient text message
  10. 103 Operation failed
  11. 104 Illegal characters
  12. 105 Too much content
  13. 106 Too many numbers
  14. 107 Frequency too fast
  15. 108 Number content is empty
  16. 109 Account frozen
  17. 110 Prohibited Frequent single message sending
  18. 111 The system is tentatively sending it
  19. 112 The number is incorrect
  20. 120 System upgrade
  21. ---------------------------------- -*/
  22. $uid = '9999'; //User account
  23. $pwd = '9999'; //Password
  24. $mobile = '13912341234,13312341234,13512341234,02122334444'; //Number
  25. $content = 'Business Line Unlimited PHP HTTP interface'; //Content
  26. //Send immediately
  27. $res = sendSMS($uid,$pwd,$mobile,$content);
  28. echo $res;
  29. //Send regularly
  30. /*
  31. $time = '2010-05-27 12:11';
  32. $res = sendSMS($uid,$pwd,$mobile,$content,$time);
  33. echo $res;
  34. */
  35. function sendSMS($uid,$ pwd,$mobile,$content,$time='',$mid='')
  36. {
  37. $http = 'http://http.c123.com/tx/';
  38. $data = array
  39. (
  40. ' uid'=>$uid, //User account
  41. 'pwd'=>strtolower(md5($pwd)), //MD5-digit 32 password
  42. 'mobile'=>$mobile, //Number
  43. 'content '=>$content, //Content
  44. 'time'=>$time, //Send regularly
  45. 'mid'=>$mid //Sub-extension number
  46. );
  47. $re= postSMS($http, $data); //POST method submission
  48. if( trim($re) == '100' )
  49. {
  50. return "Sent successfully!";
  51. }
  52. else
  53. {
  54. return "Sending failed! Status:".$ re;
  55. }
  56. }
  57. function postSMS($url,$data='')
  58. {
  59. $row = parse_url($url);
  60. $host = $row['host'];
  61. $port = $row ['port'] ? $row['port']:80;
  62. $file = $row['path'];
  63. while (list($k,$v) = each($data))
  64. {
  65. $ post .= rawurlencode($k)."=".rawurlencode($v)."&"; //Convert to URL standard code
  66. }
  67. $post = substr( $post , 0 , -1 );
  68. $len = strlen($post);
  69. $fp = @fsockopen( $host ,$port, $errno, $errstr, 10);
  70. if (!$fp) {
  71. return "$errstr ($errno)n";
  72. } else {
  73. $receive = '';
  74. $out = "POST $file HTTP/1.1rn";
  75. $out .= "Host: $hostrn";
  76. $out .= "Content-type: application/x-www -form-urlencodedrn";
  77. $out .= "Connection: Closern";
  78. $out .= "Content-Length: $lenrnrn";
  79. $out .= $post;
  80. fwrite($fp, $out);
  81. while (!feof($fp)) {
  82. $receive .= fgets($fp, 128);
  83. }
  84. fclose($fp);
  85. $receive = explode("rnrn",$receive);
  86. unset($ receive[0]);
  87. return implode("",$receive);
  88. }
  89. }
  90. ?>
  91. Detailed introduction: http://www.smsdk.com/a/gb2312/news/20111205/117.html
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn