This commit is contained in:
Denny Dai
2015-11-17 16:30:03 +08:00
parent 95169c76a6
commit d29d08b354
4 changed files with 3 additions and 3 deletions
+20
View File
@@ -0,0 +1,20 @@
<?php
class Base
{
public function exec($raw)
{
echo $raw;
return true;
}
public function msg($id, $msg)
{
return $this->exec("<xml>
<ToUserName><![CDATA[".$id."]]></ToUserName>
<FromUserName><![CDATA[".WC_UserName."]]></FromUserName>
<CreateTime>".time()."</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[".$msg."]]></Content>
<MsgId>".rand(1,9999999999999)."</MsgId>
</xml>");
}
}
+14
View File
@@ -0,0 +1,14 @@
<?php
$BOT = new Base;
$GET = $raw = file_get_contents("php://input");
//reply to...
preg_match('/<ToUserName><!\[CDATA\[(.*)\]\]><\/ToUserName>/', $raw, $FromUserName);
$FromUserName = $FromUserName[1];
preg_match('/<FromUserName><!\[CDATA\[(.*)\]\]><\/FromUserName>/', $raw, $ToUserName);
$ToUserName = $ToUserName[1];
preg_match('/<Content><!\[CDATA\[(.*)\]\]><\/Content>/', $raw, $Content);
$Content = $Content[1];
$from = $ToUserName;
$text = $Content;