本文整理汇总了PHP中WeUtility::response方法的典型用法代码示例。如果您正苦于以下问题:PHP WeUtility::response方法的具体用法?PHP WeUtility::response怎么用?PHP WeUtility::response使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WeUtility
的用法示例。
在下文中一共展示了WeUtility::response方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
public function start() {
if(empty($this->token)) {
exit('Access Denied');
}
if(!WeUtility::checkSign($this->token)) {;
exit('Access Denied');
}
if(strtolower($_SERVER['REQUEST_METHOD']) == 'get') {
exit($_GET['echostr']);
}
if(strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
$this->message = WeUtility::parse($postStr);
if (empty($this->message)) {
WeUtility::logging('waring', 'Request Failed');
exit('Request Failed');
}
WeUtility::logging('trace', $this->message);
$this->before();
$this->response = $this->matcher();
$this->response['content'] = $this->process();
if(empty($this->response['content']) || ($this->response['content']['type'] == 'text' && empty($this->response['content']['content'])) || ($this->response['content']['type'] == 'news' && empty($this->response['content']['items']))) {
$this->response['module'] = 'default';
$this->response['content'] = $this->process();
}
$this->after();
WeUtility::logging('response', $this->response);
exit(WeUtility::response($this->response['content']));
}
WeUtility::logging('waring', 'Request Failed');
exit('Request Failed');
}
示例2: hookBefore
public function hookBefore()
{
global $_W, $engine;
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
$message = WeUtility::parse($postStr);
if (!in_array($message['msgtype'], array('text', 'image'))) {
return false;
}
$member = pdo_fetch("SELECT id, lastupdate, rid, nickname, isjoin, isblacklist FROM " . tablename('wxwall_members') . " WHERE from_user = '{$message['from']}' LIMIT 1");
if (empty($member) || empty($member['isjoin'])) {
return false;
}
$wall = pdo_fetch("SELECT * FROM " . tablename('wxwall_reply') . " WHERE rid = '{$member['rid']}' LIMIT 1");
if (!empty($wall['timeout']) && $wall['timeout'] > 0 && TIMESTAMP - $member['lastupdate'] >= $wall['timeout']) {
pdo_update('wxwall_members', array('isjoin' => 0, 'lastupdate' => TIMESTAMP), array('from_user' => $message['from']));
return false;
}
if (empty($wall['quit_command']) && $message['content'] == '退出' || !empty($wall['quit_command']) && $message['content'] == $wall['quit_command']) {
pdo_update('wxwall_members', array('isjoin' => 0, 'lastupdate' => TIMESTAMP), array('from_user' => $message['from']));
$response = array();
$response['FromUserName'] = $message['to'];
$response['ToUserName'] = $message['from'];
$response['MsgType'] = 'text';
$response['Content'] = $wall['quit_tips'];
exit(WeUtility::response($response));
}
if (empty($member['nickname'])) {
$response = array();
$response['FromUserName'] = $message['to'];
$response['ToUserName'] = $message['from'];
$response['MsgType'] = 'text';
$response['Content'] = '发表话题前请<a target="_blank" href="' . $_W['siteroot'] . create_url('index/module', array('name' => 'wxwall', 'do' => 'register', 'from' => $message['from'])) . '">登记</a>您的信息。';
exit(WeUtility::response($response));
}
$data = array('rid' => $member['rid'], 'from_user' => $message['from'], 'type' => $message['type'], 'createtime' => TIMESTAMP);
if (empty($wall['isshow']) && empty($member['isblacklist'])) {
$data['isshow'] = 1;
} else {
$data['isshow'] = 0;
}
if ($message['type'] == 'text') {
$data['content'] = $message['content'];
}
if ($message['type'] == 'image') {
$image = ihttp_request($message['picurl']);
$filename = 'wxwall/' . $member['rid'] . '/' . random(30) . '.jpg';
file_write($filename, $image['content']);
$data['content'] = $filename;
}
if ($message['type'] == 'link') {
$data['content'] = iserializer(array('title' => $message['title'], 'description' => $message['description'], 'link' => $message['link']));
}
pdo_insert('wxwall_message', $data);
pdo_update('wxwall_members', array('lastupdate' => TIMESTAMP), array(from_user => $message['from']));
$engine->response = array('module' => 'wxwall', 'rule' => $member['rid']);
$engine->stat();
$response = array();
$response['FromUserName'] = $message['to'];
$response['ToUserName'] = $message['from'];
$response['MsgType'] = 'text';
$response['Content'] = htmlspecialchars_decode($wall['send_tips']);
if (!empty($member['isblacklist'])) {
$response['Content'] .= '你已被列入黑名单,发送的消息需要管理员审核!';
}
exit(WeUtility::response($response));
}
示例3: start
public function start()
{
global $_W;
if (empty($this->token)) {
exit('Access Denied');
}
if (!WeUtility::checkSign($this->token)) {
exit('Access Denied');
}
if (strtolower($_SERVER['REQUEST_METHOD']) == 'get') {
ob_clean();
ob_start();
exit($_GET['echostr']);
}
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
$this->message = WeUtility::parse($postStr);
if (empty($this->message)) {
WeUtility::logging('waring', 'Request Failed');
exit('Request Failed');
}
$sessionid = md5($this->message['from'] . $this->message['to'] . $_W['weid']);
session_id($sessionid);
WeSession::$weid = $_W['weid'];
WeSession::$from = $this->message['from'];
WeSession::$expire = 3600;
WeSession::start();
WeUtility::logging('trace', $this->message);
$pars = $this->matcher();
$pars[] = array('module' => 'default', 'rule' => '-1');
foreach ($pars as $par) {
if (empty($par['module'])) {
continue;
}
$this->params = $par;
$this->response = $this->process();
if (is_array($this->response) && ($this->response['type'] == 'text' && !empty($this->response['content']) || $this->response['type'] == 'news' && !empty($this->response['items']) || !in_array($this->type, array('text', 'news')))) {
if (!empty($par['keyword'])) {
$this->keyword = $par['keyword'];
}
break;
}
}
WeUtility::logging('params', $this->params);
WeUtility::logging('response', $this->response);
$resp = WeUtility::response($this->response);
$mapping = array('[from]' => $this->message['from'], '[to]' => $this->message['to'], '[rule]' => $this->params['rule']);
echo str_replace(array_keys($mapping), array_values($mapping), $resp);
$subscribes = array();
foreach ($_W['account']['modules'] as $m) {
if (in_array($m['name'], $this->modules) && is_array($m['subscribes']) && !empty($m['subscribes'])) {
$subscribes[] = $m;
}
}
if (!empty($subscribes)) {
$this->subscribe($subscribes);
}
exit;
}
WeUtility::logging('waring', 'Request Failed');
exit('Request Failed');
}