www.folou.com/index.php,ExpressWechat/index.php at master · Gimhoy/ExpressWechat · GitHub

error_reporting(E_ALL & ~E_NOTICE);

date_default_timezone_set("Asia/Shanghai");

require_once './weixin.class.php';

define('TOKEN', ''); //微信公众平台自定义接口处设置的 Token

define('DEBUG', false);//是否调试模式 true/false (开启调试将会把收发的信息写入文件)

define('LOGPATH', 'saestor://kuaidi/');//日志目录

define('PICTURES', false);//是否本地保存图片 true/false (开启将会本地保存用户发送图片)

$weixin = new weixin(TOKEN,DEBUG,LOGPATH,PICTURES);

$weixin->valid();

$weixin->getMsg();

$type = $weixin->msgtype;

$wei = $weixin->msg;

if ($type==='event' && $wei['Event']=='unsubscribe'){

//用户取消关注事件

file_put_contents(LOGPATH.'i.txt',date('c')."\r\n用户取消关注!\r\n",FILE_APPEND);

exit;//结束程序

}elseif(($type=='event' && $wei['Event']=='subscribe') || ($type==='text' && $wei['Content']=='Hello2BizUser')) {

//关注成功后的信息

$note = welcome();

}elseif($type==='text') {

//用户上行文本信息

$user = $wei['FromUserName'];

$text = $wei['Content'];

if(strstr($text,'@')){

$note = binding($user,$text);

}elseif(strstr($text,' ')){

$note = query($user,$text);

}elseif(substr($text,0,2) == 'qx'){

$note = qx($user,$text);

}else{

$note = auto($user,$text);

}

}elseif ($type==='location') {

//用户上行位置信息

$note = '您的位置在: '.$wei['Label'].'坐标是: X:'.$wei['Location_X'].' Y:'.$wei['Location_Y'];

}elseif ($type==='voice') {

//用户发送语音信息

$note = '暂不支持语音聊天哦';

}elseif ($type==='link') {

//用户上行连接信息

$note = '网页标题是: '.$wei['Title']."\n".'简介是:'.$wei['Description']."\n".'网址是:'.$wei['Url'];

}elseif ($type==='video') {

//用户上行视频信息

$note = '你发送了一段视频信息.';

}else{

//用户发送未知信息时回复

$note = '暂不支持此【'.$type.'】类型信息.';

}

//处理结果

$reply = $weixin->makeEter($note);

//输出

$weixin->reply($reply);

function welcome(){

return "感谢您关注快递提醒!\n您可以:\n-直接输入运单号查询快递信息\n-输入您的邮箱绑定,及时接受快递更新提醒\n-手动输入\"快递名称 单号\"查询";

}

fun

你可能感兴趣的:(www.folou.com/index.php,ExpressWechat/index.php at master · Gimhoy/ExpressWechat · GitHub)