コード例 #1
0
ファイル: wechat.inc.php プロジェクト: cwcw/cms
    if ($_G['wechat']['setting']['wechat_mtype'] != 2) {
        if (!empty($_G['cookie']['wechatopenid'])) {
            $openid = authcode($_G['cookie']['wechatopenid'], 'DECODE', $_G['config']['security']['authkey']);
        }
        if (!$openid) {
            showmessage('wechat:wechat_undefined');
        }
    } else {
        $wechat_client = new WeChatClient($_G['wechat']['setting']['wechat_appId'], $_G['wechat']['setting']['wechat_appsecret']);
        $openid = !empty($_G['cookie']['wechatopenid']) ? authcode($_G['cookie']['wechatopenid'], 'DECODE', $_G['config']['security']['authkey']) : '';
        if (!$openid) {
            if (empty($_GET['oauth'])) {
                $redirect_uri = $wechat_client->getOauthConnectUri($selfurl . $ac . '&oauth=yes');
                dheader('location: ' . $redirect_uri);
            } else {
                $tockeninfo = $wechat_client->getAccessTokenByCode($_GET['code']);
                $openid = $tockeninfo['openid'];
                dsetcookie('wechatopenid', authcode($openid, 'ENCODE', $_G['config']['security']['authkey']), 86400);
            }
        }
    }
} elseif ($openid) {
    dsetcookie('wechatopenid', authcode($openid, 'ENCODE', $_G['config']['security']['authkey']), 86400);
}
wsq::report('loginevent');
require_once libfile('function/member');
if ($openid) {
    if ($ac == 'qqbind') {
        WeChatHook::bindOpenId($_G['uid'], $openid);
        wsq::report('bind');
        $ac = 'bind';