コード例 #1
0
ファイル: save.php プロジェクト: alvin-ho/wechat-custom-cms
 $returnArr = array('code' => 200);
 if (!check_session()) {
     responseJSON('session expired', 440);
 }
 extract($_POST);
 if (!isset($appid) || !isset($app_secret)) {
     responseJSON('invalid request');
 }
 try {
     // validate app ID & app secret
     $_config = array('schema' => $_SESSION['schema'], 'appid' => $appid, 'secret' => $app_secret, 'encrypt_token' => null, 'encodingAESKey' => null, 'app_token' => null, 'app_token_expire' => null);
     // create a dummy class
     $_wechat = new WeChat($_config);
     // if id & secret are valid, access_token & expires_in will be returned
     // else errmsg & errcode will be obtained
     $result = $_wechat->validateSettings();
     if (isset($result['errcode'])) {
         $errmsg = $result['errmsg'];
         if ($result['errcode'] == 40001) {
             $errmsg = 'Invalid AppID or AppSecret.';
         } else {
             if ($result['errcode'] == 40125) {
                 $errmsg = 'Invalid AppSecret.';
             }
         }
         responseJSON($errmsg);
     }
     unset($_wechat);
     $mysql->beginTransaction();
     foreach ($SYSCONFIG['APP_CONFIG'] as $config) {
         if (isset($_POST[$config])) {