微信支付静默授权

 /**
     * 获取code非静默授权(获取用户信息用)
     * 第一步:用户同意授权,获取code
     */

    private function getUserCode($appid='zzzzzzzzzzz', $redirect_uri='http%3a%2f%2fshare.coucouchina.com') {
        $getUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$appid."&redirect_uri=".$redirect_uri."&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";

        header("Location:".$getUrl);
        exit();

    }


    /**
     * 获取code静默授权(支付用)
     * @DateTime  2018-04-27
     * @params
     * @param     string     $appid        [description]
     * @param     string     $redirect_uri [description]
     * @return    [type]                   [description]
     */
    private function getUserCode2($appid='zzzzzzz', $redirect_uri='http%3a%2f%2fshare.coucouchina.com') {
        $getUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$appid."&redirect_uri=".$redirect_uri."&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";

        header("Location:".$getUrl);
        exit();

    }

猜你喜欢

转载自blog.csdn.net/liuboxx1/article/details/80108694