Files
mier-php/application/api/wxapi/wxmsg/ReplyText.php
2025-08-11 10:22:05 +08:00

36 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\api\wxapi\wxmsg;
use app\api\wxapi\Base;
/* 回复文本消息
* */
class ReplyText extends Base{
public $BaseObject;
public function send(){
$EventKey=$this->BaseObject->EventKey; //事件KEY值与自定义菜单接口中KEY值对应
$ReplyTextModel=M("wx_reply_text")->where(['EventKey'=>$EventKey,])->order("id asc")->find();
$data['ToUserName']=$this->BaseObject->FromUserName;
$data['FromUserName']=$this->BaseObject->ToUserName;
$data['CreateTime']=time();
$data['MsgType']='text';
$str=$ReplyTextModel['Content'];
//$str="<a href='http://www.baidu.com/Wap/Shop/index.html?t={time()+60}'>登录入口,点击后失效</a><br>有效期至{date('Y-m-d H:i:s',time()+60)}";
preg_match_all("/{(.*)}/Ums",$str,$rel);
$rs=[];
foreach($rel[1] as $k=>$v){
$strs = '<?php return '.$v.'; ?>';
$rs[$k]=eval('?>'.$strs.'<?php;');
}
$Content=str_replace($rel[0],$rs,$str);
$Content=htmlspecialchars_decode($Content);
$Content=str_replace("<br>","\n",$Content);
$data['Content']=$Content;
echo $this->BaseObject->ArrayToXml($data);
}
}