<?php

/**
 * wechat php test
 */
//define your token
//define("TOKEN", "chidu4u");
$wechatObj = new wechatCallbackApi();
//$wechatObj->valid();
wechatCallbackApi::sendToBrowserNExit('');
define('HTMLPATH', "/home/chidsjwb/public_html/wxgongzhongpingtai/");
define("EXTERNALHTMLPATH", "http://chidu4u.cloudapp.net/wxgongzhongpingtai/");
define("GETACCESSTOKENPATH", "/home/chidsjwb/wxgongzhongpingtai/getAccessToken.php");
require_once HTMLPATH . 'DBvar.php';
$conn = new mysqli(DBSERVERNAME, DBUSERNAME, DBPASSWORD, DBNAME);
if ($conn->connect_errno) {
    error_log("Connect failed: %s\n", $conn->connect_error);
} else {
    mysqli_set_charset($conn, 'utf8mb4');
}
$wechatObj->responseMsg($conn);
class wechatCallbackApi
{
    public function valid()
    {
        $echoStr = $_GET["echostr"];
        //valid signature , option
        if ($this->checkSignature()) {
            echo $echoStr;
            exit;
        }
Exemple #2
0
<?php

ini_set('display_errors', false);
require_once dirname(__FILE__) . '/../model/debug.php';
require_once dirname(__FILE__) . '/../model/wechatApi.php';
include dirname(__FILE__) . '/vampire.do.php';
define("TOKEN", "zixie");
define("DEBUG", false);
if (DEBUG) {
    traceHttp();
}
$wechatObj = new wechatCallbackApi(TOKEN);
//$wechatObj->valid();
$userInput = $wechatObj->getUserInput();
if (DEBUG) {
    logger("Wechat UserInPut", $userInput);
}
$vampireObj = new vampire(DEBUG);
$resultMsg = $vampireObj->startApp($userInput);
if (DEBUG) {
    logger("Wechat ResponseMsg", $resultMsg);
}
$wechatObj->responseMsg($resultMsg);
exit;