Home > Backend Development > PHP Tutorial > PHP SMS interface basically solves the garbled problem of SMS interface.

PHP SMS interface basically solves the garbled problem of SMS interface.

WBOY
Release: 2016-07-25 09:07:51
Original
1789 people have browsed it
The PHP SMS interface basically solves the problem of garbled characters when PHP calls the SMS interface. The code is not complicated, but it is still practical.

The following SMS interface supports long text messages and replies. Here, I only share the sending function. Friends in need can refer to 56 SMS Network

The website is: http://www.56dxw.com and the speed is pretty good.
  1. reg.php file
  2. session_start();
  3. ?>
  4. 56 SMS Network Example (http://www.56dxw.com)
  5. < ;?
  6. $action=$_GET["action"];
  7. if ($action=='add')
  8. {
  9. $Code=trim($_POST["t_num"]);
  10. // print($Code );
  11. if($Code==$_SESSION["code"])
  12. print( "<script>alert('Token successful')</script>");
  13. else
  14. print( "");
  15. unset($_SESSION['code']);
  16. }
  17. ?>
  18. Your mobile number:


  19. Verification code:


  20.  

Copy code
  1. sms.php file
  2. session_start();
  3. error_reporting(0);
  4. header("content-type:text ml;charset=gb2312");
  5. //Account configuration file
  6. $ comid= "60"; //Enterprise ID
  7. $username= "test1"; //Username
  8. $userpwd= "qwqwqw"; //Password
  9. $smsnumber= "1061"; //Platform used
  10. function rstr($str){
  11. if($str==1)
  12. $error='Represents successful sending';
  13. else{
  14. switch($str){
  15. case -1:$error='Mobile phone number is incorrect' ;break;
  16. case -2:$error='Except time, all parameters cannot be empty';break;
  17. case -3:$error='Username and password are incorrect';break;
  18. case -4:$error ='The platform does not exist';break;
  19. case -5:$error='The number of customer SMS messages is 0';break;
  20. case -6:$error='The customer account balance is less than the number of messages to be sent';break;
  21. case -8:$error='Illegal text message content';break;
  22. case -9:$error='Unknown system failure';break;
  23. case -10:$error='Network error';break;
  24. default: $error='Unknown error';
  25. }
  26. }
  27. print($error);
  28. exit();
  29. }
  30. function sendnote($mobtel,$msg){
  31. global $username,$userpwd,$smsnumber, $comid;
  32. $url = "http://jiekou.56dxw.com/sms/HttpInterface.aspx?comid=$comid&username=$username&userpwd=$userpwd&handtel=$mobtel&sendcontent=$msg&sendtime=&smsnumber=$smsnumber";
  33. $string = file_get_contents($url);
  34. return rstr($string);
  35. }
  36. $_SESSION["code"]="12365";
  37. $handtel =$_POST["Tel"];
  38. $msg="Mobile phone verification code Is: ".$_SESSION["code"];
  39. !$handtel && die('Mobile phone number required');
  40. !$msg && die('Occurrence content required');
  41. echo sendnote($_POST[ "Tel"],urlencode($msg));
  42. ?>
Copy code
PHP SMS interface basically solves the garbled problem of SMS interface.


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