Detailed explanation of the method of intercepting the content of launched text messages in PHP

墨辰丷
Release: 2023-03-27 06:08:02
Original
1116 people have browsed it

This article mainly introduces the method of intercepting the content of text messages with PHP. Friends who need it can refer to it

The specific code is as follows:

$str_tmp  = DAdmin_Utils::gbkStrSplit(“短信内容”, 700);//内容过长返回的是一个截取内容后的数组  700指的是截取的长度
    $total = count($str_tmp);
    $num  = 1;
    foreach($str_tmp as $str)
    {
      if($total > 1)
      {
       $str = $str . "{$num}/{$total}";
       $num ++;
      }
      $sign = strtoupper(md5($key.$pMobile.$str.$ip));
      $url = "短信地址?from=37&sgin=".$sign."&tel=".$pMobile."&msg=".$str;
      $ret = file_get_contents($url);
      $result = json_decode($ret,true);
    }
//发送短信方法
function gbkStrSplit($string, $len = 1)
  {
    $length = strlen($string);//获取长度,汉字占三个字节
    $retstr = '';
    $retArr = array();
    for ($i = 0; $i < $length; $i++) {
      $retstr .= ord($string[$i]) > 127 ? $string[$i] . $string[++$i] : $string[$i];
      $len_tmp = strlen($retstr);
      if ($len_tmp >= $len) {
        $retArr[] = $retstr;
        $retstr = &#39;&#39;;
      }
    }
    if ($retstr != &#39;&#39;) {
      $retArr[] = $retstr;
    }
    return $retArr;
  }
Copy after login

Related recommendations:

How to use yunpian.net to implement SMSVerification code function

laravel operation SMSDetailed explanation of the steps to implement the function of sending verification code

##253SMSInterface PHP calls directly

The above is the detailed content of Detailed explanation of the method of intercepting the content of launched text messages in PHP. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!