Home > Backend Development > PHP Tutorial > SMS platform PHP code

SMS platform PHP code

WBOY
Release: 2016-07-25 09:02:19
Original
1307 people have browsed it
$flag = 0;
//Data to be posted
$argv = array(
'sn'=>'SDK-BBX-010-XXXXX',
'pwd'=>'XXXXXX',
'mobile'=>'15201692834',
'content'=>'How are you, test text message'
);
//Construct the string to be posted
foreach ($argv as $key=>$value) {
if ($flag!=0) {
$params .= "&";
$flag = 1;
}
$params.= $key."="; $params.= urlencode($value);
$flag = 1;
}
$length = strlen($params);
//Create socket connection
$fp = fsockopen("sdk2.entinfo.cn",80,$errno,$errstr,10) or exit($errstr."--->".$errno);
//Construct the header of the post request
$header = "POST /z_send.aspx HTTP/1.1rn";
$header .= "Host:sdk2.entinfo.cnrn";
$header .= "Referer:/mobile/sendpost.phprn";
$header .= "Content-Type: application/x-www-form-urlencodedrn";
$header .= "Content-Length: ".$length."rn";
$header .= "Connection: Closernrn";
//Add post string
$header .= $params."rn";
//Send post data
fputs($fp,$header);
$inheader = 1;
while (!feof($fp)) {
$line = fgets($fp,1024); //Remove the header of the request packet and only display the return data of the page
if ($inheader && ($line == "n" || $line == "rn")) {
$inheader = 0;
}
if ($inheader == 0) {
// echo $line;
}
}
if($line==1)
{
echo 'SMS sent successfully, please check the return value'.$line;
}else
{
echo 'Failed to send SMS, please check related error issues according to the return value. Return value'.$line;
}
fclose($fp);
  1. $flag = 0;
  2. //Data to be posted
  3. $argv = array(
  4. 'sn'=>'SDK-BBX-010-XXXXX',
  5. 'pwd'=> ;'XXXXXX',
  6. 'mobile'=>'15201692834',
  7. 'content'=>'How are you, test text message'
  8. );
  9. //Construct the string to be posted
  10. foreach ($argv as $ key=>$value) {
  11. if ($flag!=0) {
  12. $params .= "&";
  13. $flag = 1;
  14. }
  15. $params.= $key."="; $params. = urlencode($value);
  16. $flag = 1;
  17. }
  18. $length = strlen($params);
  19. //Create a socket connection
  20. $fp = fsockopen("sdk2.entinfo.cn",80,$errno, $errstr,10) or exit($errstr."--->".$errno);
  21. //Construct the header of the post request
  22. $header = "POST /z_send.aspx HTTP/1.1rn";
  23. $header .= "Host:sdk2.entinfo.cnrn";
  24. $header .= "Referer:/mobile/sendpost.phprn";
  25. $header .= "Content-Type: application/x-www-form-urlencodedrn";
  26. $header .= "Content-Length: ".$length."rn";
  27. $header .= "Connection: Closernrn";
  28. //Add the post string
  29. $header .= $params."rn";
  30. //Send post data
  31. fputs($fp,$header);
  32. $inheader = 1;
  33. while (!feof($fp)) {
  34. $line = fgets($fp,1024); //Remove request packet The header only displays the return data of the page
  35. if ($inheader && ($line == "n" || $line == "rn")) {
  36. $inheader = 0;
  37. }
  38. if ($inheader == 0 ) {
  39. // echo $line;
  40. }
  41. }
  42. if($line==1)
  43. {
  44. echo 'SMS sent successfully, please check the return value'.$line ;
  45. }else
  46. {
  47. echo 'SMS sent failed , please check the related error issues based on the return value. $line
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template