This article shares a PHP SMS interface code, very simple, for beginners to refer to friends, if the site useful to the text messaging interface function, this example can be used for reference. PHP SMS Interface file:
$uid,//user account ' pwd ' =>strtolower (MD5 ($PWD)),//md5-bit 32 password ' mobile ' + $mobile,//number ' content ' = + $content,// Content ' time ' = $time,//timed to send ' mid ' + $mid//Sub-extension number); $re = Postsms ($http, $data); Post method Submit if (trim ($re) = = ' + ') {return ' sent 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)." & "; Go 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.1\r\n"; $out. = "Host: $host \ r \ n"; $out. = "content-type:application/x-www-form-urlencoded\r\n"; $out. = "connection:close\r\n"; $out. = "Content-length: $len \r\n\r\n"; $out. = $post; Fwrite ($fp, $out); while (!feof ($fp)) {$receivE. = Fgets ($fp, 128); } fclose ($FP); $receive = Explode ("\r\n\r\n", $receive); unset ($receive [0]); Return implode ("", $receive);}}? > Guess you like: PHP Short message sending function example code of PHP SMS interface function |