public function index() { if (!class_exists('SimpleXMLElement')) { exit('SimpleXMLElement class not exist'); } if (!function_exists('dom_import_simplexml')) { exit('dom_import_simplexml function not exist'); } $this->token = $this->_get('token', "htmlspecialchars"); if (!preg_match("/^[0-9a-zA-Z]{3,42}\$/", $this->token)) { exit('error token'); } $weixin = new Wechat($this->token); $data = $weixin->request(); $this->data = $weixin->request(); $this->fans = S('fans_' . $this->token . '_' . $this->data['FromUserName']); if (!$this->fans || 1) { $this->fans = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->find(); S('fans_' . $this->token . '_' . $this->data['FromUserName'], $this->fans); } $this->wxuser = S('wxuser_' . $this->token); if (!$this->wxuser || 1) { $this->wxuser = D('Wxuser')->where(array('token' => $this->token))->find(); S('wxuser_' . $this->token, $this->wxuser); } $this->my = C('site_my'); $this->apiServer = apiServer::getServerUrl(); $open = M('Token_open')->where(array('token' => $this->_get('token')))->find(); $this->fun = $open['queryname']; list($content, $type) = $this->reply($data); $weixin->response($content, $type); }
public function index() { $this->token = $this->_get('token'); $weixin = new Wechat($this->token); $data = $weixin->request(); $this->data = $weixin->request(); $this->my = C('site_my'); list($content, $type) = $this->reply($data); $weixin->response($content, $type); }
public function index() { $this->token = $this->_get('token', "htmlspecialchars"); if (!preg_match("/^[0-9a-zA-Z]{3,42}$/", $this->token)) { exit('error token'); } $weixin = new Wechat($this->token); $data = $weixin->request(); $this->data = $weixin->request(); $this->my = C('site_my'); $open = M('Token_open')->where(array( 'token' => $this->_get('token') ))->find(); $this->fun = $open['queryname']; list($content, $type) = $this->reply($data); $weixin->response($content, $type); }
public function index() { $this->token = $this->_get('token'); $this->my = C('site_my'); # Log::record('weixinmsg',Log::DEBUG); # Log::record('weixinmsg',$this->token,Log::DEBUG); # Log::save(); # $this->siteName = C('site_name'); $weixin = new Wechat($this->token); //$data = $weixin->request(); //$this->xml = $weixin->xml; $this->data = $weixin->request(); //是否是在上墙中 if ($this->data) { $data = $this->data; $users = S($data['FromUserName'] . 'wxq'); if ($users != false) { $res = $this->wxq($users); } else { $res = $this->reply($data); } list($content, $type) = $res; $weixin->response($content, $type); } }
public function index() { $thisurl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $rt = explode('index.php', $thisurl); $arg = isset($rt[1]) ? $rt[1] : ''; if (!empty($arg)) { $rt = explode('/', $arg); $arg = isset($rt[1]) ? $rt[1] : ''; if (!empty($arg)) { $this->token = trim($arg); } } if (!class_exists('SimpleXMLElement')) { exit('SimpleXMLElement class not exist'); } if (!function_exists('dom_import_simplexml')) { exit('dom_import_simplexml function not exist'); } if (!preg_match("/^[0-9a-zA-Z]{3,42}\$/", $this->token)) { exit('error token'); } $weixin = new Wechat($this->token); $this->data = $weixin->request(); if ($this->data) { list($content, $type) = $this->reply($this->data); $weixin->response($content, $type); } }
public function index() { $this->token = 'cmgeshengli'; $weixin = new \Wechat($this->token); $this->data = $weixin->request(); list($content, $type) = $this->reply($this->data); $weixin->response($content, $type); }
public function index() { $this->siteUrl = C('site_url'); if (!class_exists('SimpleXMLElement')) { exit('SimpleXMLElement class not exist'); } if (!function_exists('dom_import_simplexml')) { exit('dom_import_simplexml function not exist'); } $this->token = $this->_get('token', "htmlspecialchars"); if ($this->token == 'pigcms' || $this->token == 'qcloud') { $qcloudUser = M('Qcloud_user')->where(array('openid' => $this->_get('openId')))->find(); $this->token = $qcloudUser['token']; } if (!preg_match("/^[0-9a-zA-Z]{3,42}\$/", $this->token)) { exit('error token'); } $weixin = new Wechat($this->token, $this->wxuser); $this->wxuser = S('wxuser_' . $this->token); if (!$this->wxuser || 1) { $this->wxuser = D('Wxuser')->where(array('token' => $this->token))->find(); if (C('agent_version') && intval($this->wxuser['agentid'])) { $thisAgent = M('Agent')->where(array('id' => $this->wxuser['agentid']))->find(); $this->siteUrl = $thisAgent['siteurl']; } S('wxuser_' . $this->token, $this->wxuser); } $this->user = M('Users')->where(array('id' => $this->wxuser['uid']))->find(); $weixin = new Wechat($this->token, $this->wxuser); $data = $weixin->request(); $this->data = $weixin->request(); $this->fans = S('fans_' . $this->token . '_' . $this->data['FromUserName']); if (!$this->fans || 1) { $this->fans = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->find(); S('fans_' . $this->token . '_' . $this->data['FromUserName'], $this->fans); } //自定义机器人名字 $this->my = C('site_my'); $this->apiServer = apiServer::getServerUrl(); $open = M('Token_open')->where(array('token' => $this->_get('token')))->find(); $this->fun = $open['queryname']; list($content, $type) = $this->reply($data); $weixin->response($content, $type); }
public function index() { $this->siteUrl = C('site_url'); if (!class_exists('SimpleXMLElement')) { die('SimpleXMLElement class not exist'); } if (!function_exists('dom_import_simplexml')) { die('dom_import_simplexml function not exist'); } $this->token = $this->_get('token', 'htmlspecialchars'); if (!preg_match('/^[0-9a-zA-Z]{3,42}$/', $this->token)) { die('error token'); } $this->mykey = trim(C('server_key')); $weixin = new Wechat($this->token); $data = $weixin->request(); $this->data = $weixin->request(); if ($this->data) { //自定义机器人名字 $this->fans = S((('fans_' . $this->token) . '_') . $this->data['FromUserName']); if (!$this->fans || 1) { $this->fans = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->find(); S((('fans_' . $this->token) . '_') . $this->data['FromUserName'], $this->fans); } $this->wxuser = S('wxuser_' . $this->token); if (!$this->wxuser || 1) { $this->wxuser = D('Wxuser')->where(array('token' => $this->token))->find(); //判断账号是否到期 $wxuser = M('Wxuser')->where(array('token' => $this->token))->find(); $users = M('Users')->where(array('id' => $wxuser['uid']))->find(); if ($users['viptime'] < strtotime(date('Y-m-d H:i:s'))) { $weixin->response('帐号过期,请联系客服!', 'text'); return; } S('wxuser_' . $this->token, $this->wxuser); } $this->my = C('site_my'); $this->apiServer = apiServer::getServerUrl(); $open = M('Token_open')->where(array('token' => $this->_get('token')))->find(); $this->fun = $open['queryname']; list($content, $type) = $this->reply($data); $weixin->response($content, $type); } }
public function index() { $wechat = new Wechat($this->config); $data = $wechat->request(); list($content, $type) = $this->reply($data); if (!empty($content)) { $wechat->response($content, $type); } else { exit; } }
public function index() { Vendor('weixin.Wechat#class'); $this->token = $this->_get('token'); $wall = M('wall')->find(); $this->functionw = $wall['function']; $vote = M('vote')->find(); $this->functionv = $vote['function']; $publicnum = M('publicnum')->find(); $this->appid = $publicnum['appid']; $this->appsecret = $publicnum['appsecret']; $this->username = $publicnum['username']; $this->password = $publicnum['password']; $this->time = $publicnum['time']; if ($this->token == md5($publicnum['original'])) { $weixin = new Wechat($this->token); $data = $weixin->request(); $this->data = $weixin->request(); $this->url = $_SERVER['HTTP_HOST']; list($content, $type) = $this->reply($data); $weixin->response($content, $type); } echo $this->appid; }
/** * 接收微信服务器消息的入口函数 */ public function index() { try { $wechat = new Wechat(TOKEN, APPID, EncodingAESKey); /* 加载微信SDK */ $data = $wechat->request(); /* 获取请求信息 */ if ($data && is_array($data)) { file_put_contents('./data.json', json_encode($data)); //记录微信推送过来的数据 $this->response($wechat, $data); //对消息做出响应 } } catch (\Exception $e) { file_put_contents('./error.json', json_encode($e->getMessage())); } }
public function index($ApiData = '') { if ($ApiData != '') { $_GET = $ApiData; } $this->ali = 0; if (isset($_GET['ali']) && intval($_GET['ali'])) { $this->ali = 1; } $this->siteUrl = C('site_url'); if (!class_exists('SimpleXMLElement')) { exit('SimpleXMLElement class not exist'); } if (!function_exists('dom_import_simplexml')) { exit('dom_import_simplexml function not exist'); } if (empty($_GET['token']) && isset($_GET['appid'])) { $appid = ltrim($_GET['appid'], '/'); $this->token = M('Wxuser')->where('appid=\'' . $appid . '\'')->getField('token'); } else { $this->token = htmlspecialchars($_GET['token']); } if ($appid == 'wx570bc396a51b8ff8') { $wxarr['type'] = 1; $wxarr['encode'] = 2; $oauth = new Wechat($appid, $wxarr); $apiOauth = new apiOauth(); $data = $oauth->request(); $openid = $data['FromUserName']; $ToUserName = $data['ToUserName']; switch ($data['MsgType']) { case 'text': if ($data['Content'] == 'TESTCOMPONENT_MSG_TYPE_TEXT') { $content = 'TESTCOMPONENT_MSG_TYPE_TEXT_callback'; $oauth->response($content); } else if (strstr($data['Content'], 'QUERY_AUTH_CODE')) { $auth_code = str_replace('QUERY_AUTH_CODE:', '', $data['Content']); $authorization_info = $apiOauth->get_authorization_info($auth_code); $access_token = $authorization_info['authorizer_access_token']; $url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $access_token; $content = $auth_code . '_from_api'; $call = '{' . "\r\n" . ' "touser":"******",' . "\r\n" . ' "msgtype":"text",' . "\r\n" . ' "text":' . "\r\n" . ' {' . "\r\n" . ' "content":"' . $content . '"' . "\r\n" . ' }' . "\r\n" . ' }'; $apiOauth->https_request($url, $call); } break; case 'event': $content = $data['Event'] . 'from_callback'; $oauth->response($content); break; } exit(); } if (($this->token == 'pigcms') || ($this->token == 'qcloud')) { $qcloudUser = M('Qcloud_user')->where(array('openid' => $_GET['openId']))->find(); $this->token = $qcloudUser['token']; } if (!preg_match('/^[0-9a-zA-Z]{3,42}$/', $this->token)) { exit('error token'); } if (!$this->ali) { $weixin = new Wechat($this->token, $this->wxuser); } $this->wxuser = S('wxuser_' . $this->token); if (!$this->wxuser || 1) { $this->wxuser = D('Wxuser')->where(array('token' => $this->token))->find(); if (C('agent_version') && intval($this->wxuser['agentid'])) { $thisAgent = M('Agent')->where(array('id' => $this->wxuser['agentid']))->find(); $this->siteUrl = $thisAgent['siteurl']; } S('wxuser_' . $this->token, $this->wxuser); } $this->user = M('Users')->where(array('id' => $this->wxuser['uid']))->find(); if (!$this->ali) { $data = $weixin->request(); $this->data = $weixin->request(); } $this->fans = S('fans_' . $this->token . '_' . $this->data['FromUserName']); if (!$this->fans || 1) { $this->fans = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->find(); S('fans_' . $this->token . '_' . $this->data['FromUserName'], $this->fans); } $session_openid_name = 'token_openid_' . $this->token; $_SESSION[$session_openid_name] = $this->data['FromUserName']; $this->my = C('site_my'); $this->apiServer = apiServer::getServerUrl(); $open = M('Token_open')->where(array('token' => $this->token))->find(); $this->fun = $open['queryname']; if (!$this->ali) { list($content, $type) = $this->reply($data); $weixin->response($content, $type); } else { $data = array(); $data['Content'] = htmlspecialchars($_GET['keyword']); $data['FromUserName'] = htmlspecialchars($_GET['fromUserName']); $data['FromUserName'] = '******' . md5($data['FromUserName']); if (isset($_GET['eventType']) && $_GET['eventType']) { $data['Event'] = trim(htmlspecialchars($_GET['eventType'])); if ($data['Event'] == 'SCAN') { $data['EventKey'] = $_GET['EventKey']; $eventReplyClassName = 'SCANEventReply'; class_exists($eventReplyClassName); $SCANEventReply = new $eventReplyClassName($this->token, $data['FromUserName'], $data, $this->siteUrl, $this->ali); return $SCANEventReply->index(); } } $this->data = $data; return $this->reply($data); } }
function index() { $thisurl = Import::basic()->thisurl(); $rt = explode('index.php', $thisurl); $arg = isset($rt[1]) ? $rt[1] : ''; if (!empty($arg)) { $rt = explode('/', $arg); $arg = isset($rt[1]) ? $rt[1] : ''; if (!empty($arg)) { $this->token = trim($arg); } else { $t = isset($_GET['t']) ? $_GET['t'] : ''; if (empty($t)) { die('参数为空'); } else { $this->token = $t; } } } else { $t = isset($_GET['t']) ? $_GET['t'] : ''; if (empty($t)) { die('参数为空'); } else { $this->token = $t; } } $ss = $this->token; $sql = "SELECT pigsecret FROM `{$this->App->prefix()}wxuserset` WHERE token='{$ss}' LIMIT 1"; $pigsecret = $this->App->findvar($sql); if (empty($pigsecret)) { $pigsecret = "isempty"; } if (!class_exists('SimpleXMLElement')) { die('SimpleXMLElement class not exist'); } if (!function_exists('dom_import_simplexml')) { die('dom_import_simplexml function not exist'); } if (!preg_match('/^[0-9a-zA-Z]{3,42}$/', $this->token)) { die('Error token'); } //包含 if (!class_exists('Wechat')) { require_once SYS_PATH_API . 'inc/Wechat.class.php'; } $weixin = new Wechat($pigsecret); $data = $weixin->request(); $this->data = $data; if ($this->data) { //自定义机器人名字 $wecha_id = $this->data['FromUserName']; $token = $this->token; $this->Session->write('User.wecha_id', $wecha_id); $this->Session->write('User.token', $token); setcookie(CFGH . 'USER[UKEY]', $wecha_id, mktime() + 2592000); $this->fans = $this->App->findrow("SELECT * FROM `{$this->App->prefix()}user` WHERE wecha_id='{$wecha_id}' "); $this->wxuser = '******' . $this->token; $this->apiServer = 'http://api.apiqq.com'; $this->fun = ''; //这里是允许访问的权限 $this->wecha_id = $wecha_id; list($content, $type) = $this->reply($data); $weixin->response($content, $type); } }
<?php define('PIGCMS_PATH', dirname(dirname(__FILE__)) . '/'); require_once PIGCMS_PATH . 'source/init.php'; $t_configs = D('Config')->field('`name`,`value`')->select(); foreach ($t_configs as $key => $value) { $t_config[$value['name']] = $value['value']; } $_G['config'] = $t_config; $action = isset($_GET['a']) ? addslashes($_GET['a']) : 'index'; import("source.class.Wechat"); $wechat = new Wechat($t_config); if ($action == 'index') { $data = $wechat->request(); list($content, $type) = reply($data); $wechat->response($content, $type); } elseif ($action == 'get_ticket') { //获取 component_verify_ticket 每十分钟微信服务本服务器请求一次 $data = $wechat->request(); if (isset($data['InfoType'])) { if ($data['InfoType'] == 'component_verify_ticket') { if (isset($data['ComponentVerifyTicket']) && $data['ComponentVerifyTicket']) { if ($config = D('Config')->where("`name`='wx_componentverifyticket'")->find()) { D('Config')->where("`name`='wx_componentverifyticket'")->data(array('value' => $data['ComponentVerifyTicket']))->save(); } else { D('Config')->data(array('name' => 'wx_componentverifyticket', 'value' => $data['ComponentVerifyTicket'], 'type' => 'type=text', 'gid' => 0, 'tab_id' => 0))->add(); } F('config', null); exit('success'); } } elseif ($data['InfoType'] == 'unauthorized') {
public function index($ApiData = '') { if ($ApiData != "") { $_GET = $ApiData; } $this->ali = 0; if (isset($_GET["ali"]) && intval($_GET["ali"])) { $this->ali = 1; } $this->siteUrl = C("site_url"); if (!class_exists("SimpleXMLElement")) { exit("SimpleXMLElement class not exist"); } if (!function_exists("dom_import_simplexml")) { exit("dom_import_simplexml function not exist"); } if (empty($_GET["token"]) && isset($_GET["appid"])) { $appid = ltrim($_GET["appid"], "/"); $this->token = M("Wxuser")->where("appid='{$appid}'")->getField("token"); } else { $this->token = htmlspecialchars($_GET["token"]); } if ($appid == "wx570bc396a51b8ff8") { $wxarr["type"] = 1; $wxarr["encode"] = 2; $oauth = new Wechat($appid, $wxarr); $apiOauth = new apiOauth(); $data = $oauth->request(); $openid = $data["FromUserName"]; $ToUserName = $data["ToUserName"]; switch ($data["MsgType"]) { case "text": if ($data["Content"] == "TESTCOMPONENT_MSG_TYPE_TEXT") { $content = "TESTCOMPONENT_MSG_TYPE_TEXT_callback"; $oauth->response($content); } else { if (strstr($data["Content"], "QUERY_AUTH_CODE")) { $auth_code = str_replace("QUERY_AUTH_CODE:", "", $data["Content"]); $authorization_info = $apiOauth->get_authorization_info($auth_code); $access_token = $authorization_info["authorizer_access_token"]; $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" . $access_token; $content = $auth_code . "_from_api"; $call = "{\r\n\t\t\t\t\t\t\t\t\t\"touser\":\"" . $openid . "\",\r\n\t\t\t\t\t\t\t\t\t\"msgtype\":\"text\",\r\n\t\t\t\t\t\t\t\t\t\"text\":\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t \"content\":\"" . $content . "\"\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}"; $apiOauth->https_request($url, $call); } } break; case "event": $content = $data["Event"] . "from_callback"; $oauth->response($content); break; } exit; } if ($this->token == "weimicms" || $this->token == "qcloud") { $qcloudUser = M("Qcloud_user")->where(array("openid" => $_GET["openId"]))->find(); $this->token = $qcloudUser["token"]; } if (!preg_match("/^[0-9a-zA-Z]{3,42}\$/", $this->token)) { exit("error token"); } if (!$this->ali) { $weixin = new Wechat($this->token, $this->wxuser); } $this->wxuser = S("wxuser_" . $this->token); if (!$this->wxuser || 1) { $this->wxuser = D("Wxuser")->where(array("token" => $this->token))->find(); if (C("agent_version") && intval($this->wxuser["agentid"])) { $thisAgent = M("Agent")->where(array("id" => $this->wxuser["agentid"]))->find(); $this->siteUrl = $thisAgent["siteurl"]; } S("wxuser_" . $this->token, $this->wxuser); } $this->user = M("Users")->where(array("id" => $this->wxuser["uid"]))->find(); if (!$this->ali) { $data = $weixin->request(); $this->data = $weixin->request(); } $this->mykey = trim(C('server_key')); $this->chatkey = trim(C('site_chatkey')); $weixin = new Wechat($this->token); $data = $weixin->request(); $this->data = $weixin->request(); if ($this->data) { //自定义机器人名字 $this->fans = S("fans_" . $this->token . "_" . $this->data["FromUserName"]); if (!$this->fans || 1) { $this->fans = M("Userinfo")->where(array("token" => $this->token, "wecha_id" => $this->data["FromUserName"]))->find(); S("fans_" . $this->token . "_" . $this->data["FromUserName"], $this->fans); } $session_openid_name = "token_openid_" . $this->token; $_SESSION[$session_openid_name] = $this->data["FromUserName"]; $this->my = C("site_my"); $this->apiServer = apiServer::getServerUrl(); $open = M("Token_open")->where(array("token" => $this->token))->find(); $this->fun = $open["queryname"]; if (!$this->ali) { list($content, $type) = $this->reply($data); $weixin->response($content, $type); } else { $data = array(); $data["Content"] = htmlspecialchars($_GET["keyword"]); $data["FromUserName"] = htmlspecialchars($_GET["fromUserName"]); $data["FromUserName"] = "******" . md5($data["FromUserName"]); if (isset($_GET["eventType"]) && $_GET["eventType"]) { $data["Event"] = trim(htmlspecialchars($_GET["eventType"])); if ($data["Event"] == "SCAN") { $data["EventKey"] = $_GET["EventKey"]; $eventReplyClassName = "SCANEventReply"; class_exists($eventReplyClassName); $SCANEventReply = new $eventReplyClassName($this->token, $data["FromUserName"], $data, $this->siteUrl, $this->ali); return $SCANEventReply->index(); } } $this->data = $data; return $this->reply($data); } } }