reply() public method

回复微信服务器, 此函数支持链式操作 Example: $this->text('msg tips')->reply();
public reply ( string $msg = [], boolean $return = false )
$msg string 要发送的信息, 默认取$this->_msg
$return boolean 是否返回信息而不抛出到浏览器 默认:否
Example #1
0
define("TEXT", "【校园资讯-回复数字或提示】\n[1]广药新闻\t[2]就业信息\n[3]图书信息\t[cet]查四六级\n[5]动漫更新\t[6]交通卡余额\n[7]查课表\t[8]发找找帮\n[9]勤管兼职\t[10]查成绩\n[11]查选修\t[开]开户指南\n\n【生活服务-回复字母】\n[A]听歌\t[B]公交\t[C]翻译\t[D]快递\n[E]解梦\t[F]手机\t[G]身份\t[H]音乐\t\n[T]天气\n聊天: 任意回复\t\t提意见?回复意见\n\n上不了校园网?回复:校园网故障查询 或者 报障 或者 114.w\n\n合作事宜: 回复 合作 或 推送");
// 星标标识,默认为* ,用户对话里包含此标识则设置为星标,用于留言
define("FLAG", "*");
// 这里为你的私有库账号
$yourdb = "gdpuer";
$yourpw = "ourstudio";
$welcome = '欢迎关注广药小助手';
// 配置结束
$w = new Wechat(TOKEN, DEBUG);
// 首次验证,验证过以后可以删掉
if (isset($_GET['echostr'])) {
    $w->valid();
    exit;
}
// 回复用户
$w->reply("reply_main");
// 后续必要的处理...
/* TODO */
exit;
function reply_main($request, $w)
{
    $to = $request['ToUserName'];
    $from = $request['FromUserName'];
    // 大众接口
    if ($w->get_msg_type() == "location") {
        $lacation = "x@" . (string) $request['Location_X'] . "@" . (string) $request['Location_Y'];
        $lacation = urlencode(str_replace('\\.', '\\\\.', $lacation));
        $lacation = urldecode(xiaojo($lacation, $from, $to));
        return $lacation;
    } else {
        if ($w->get_msg_type() == "image") {
Example #2
0
        break;
}
if (bind_check()) {
    if ($operation == BIND) {
        $text = ALREADY_BINDED;
    } else {
        if ($operation == HOT) {
            $text = search(NULL, HOT);
        } else {
            if ($operation == NEWLY) {
                $text = search(NULL, NEWLY);
            } else {
                if ($operation == STATUS) {
                    $text = user_status();
                } else {
                    if ($operation == SEARCH) {
                        $text = search($keyword, NULL);
                    } else {
                        $text = HELP;
                    }
                }
            }
        }
    }
} else {
    $text = user_bind();
}
//echo $text;
$weObj->text($text);
$weObj->reply();
Example #3
0
header("content-Type: text/html; charset=utf-8");
include "wechat.php";
include "db.php";
define("MOREN", "title|欢迎关注{$weixin_name}#pic|回话题加你想说的话,审核通过后即可上墙~");
//添加帐号的默认回复
define("FLAG", "@");
//星标标识,默认为 @,用户对话里包含此标识则设置为星标,用于留言
//配置结束
$w = new Wechat(TOKEN, DEBUG);
if (isset($_GET['echostr'])) {
    $w->valid();
    exit;
}
//回复用户
$w->reply("reply_cb");
exit;
function reply_cb($request, $w)
{
    $to = $request['ToUserName'];
    $from = $request['FromUserName'];
    $time = $w->get_creattime();
    if ($w->get_msg_type() == "location") {
        $lacation = "x@" . (string) $request['Location_X'] . "@" . (string) $request['Location_Y'];
        $lacation = urlencode(str_replace('\\.', '\\\\.', $lacation));
        $lacation = urldecode(xiaojo($lacation, $from, $to));
        return $lacation;
    } else {
        if ($w->get_msg_type() == "image") {
            $PicUrl = $request['PicUrl'];
            $pic = urldecode(xiaojo("&" . $PicUrl, $from, $to));