getRevData() публичный Метод

获取微信服务器发来的信息
public getRevData ( )
Пример #1
0
<?php

include_once "common.php";
$weObj = new Wechat($wechatoptions);
$weObj->valid();
//明文或兼容模式可以在接口验证通过后注释此句,但加密模式一定不能注释,否则会验证失败
$type = $weObj->getRev()->getRevType();
switch ($type) {
    case Wechat::MSGTYPE_TEXT:
        $revdata = $weObj->getRevData();
        $super = in_array($revdata['FromUserName'], $testusers) ? 1 : 0;
        //是否特殊用户
        if ($super) {
            if ("report" == $revdata['Content']) {
                //$text = curl('http://119.29.78.76/gdmuwx/report.php');
                $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('wxtextmsg') . " WHERE status='0'");
                $text = '';
                while ($read = $_SGLOBAL['db']->fetch_array($query)) {
                    foreach ($read as $key => $value) {
                        $text .= $key . ' : ' . $value . "\n";
                    }
                    $text .= "\n";
                }
                if (empty($text)) {
                    $text = 'no new message';
                } else {
                    $text = substr($text, 0, strlen($text) - 2 * strlen("\n"));
                    updatetable('wxtextmsg', array('status' => 1), array('status' => 0));
                }
                $weObj->text($text)->reply();
                exit;
Пример #2
0
<?php

include "../qywechat.class.php";
function logg($text)
{
    file_put_contents('./log.txt', $text . "\r\n\r\n", FILE_APPEND);
}
$options = array('token' => '9xxxxxxxxxxxx', 'encodingaeskey' => 'd4oxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'appid' => 'wxa0xxxxxxxxxx', 'debug' => true, 'logcallback' => 'logg');
logg("GET参数为:\n" . var_export($_GET, true));
$weObj = new Wechat($options);
$ret = $weObj->valid();
if (!$ret) {
    logg("验证失败!");
    var_dump($ret);
    exit;
}
$f = $weObj->getRev()->getRevFrom();
$t = $weObj->getRevType();
$d = $weObj->getRevData();
$weObj->text("你好!来自星星的:" . $f . "\n你发送的" . $t . "类型信息:\n原始信息如下:\n" . var_export($d, true))->reply();
logg("-----------------------------------------");