zoukankan      html  css  js  c++  java
  • QQ登陆接口

    这次做了一个QQ登陆接口---简单记录一下

    遇到一大坑-----QQ互联里面添加应用的时候,是网站应用,配置回调地址一定要配置  准确,到指定回调页面 否则会出现问题的。

    1、首先引用基类  QQConnect.cs     代码下载
    2、新建 Index.aspx

        private string AppId = AuthConnect.QQ_AppId;
        private string AppKey = AuthConnect.QQ_AppKey;
        private string CallbackUrl = AuthConnect.QQ_CallbackUrl;
    
        QQConnect connect = new QQConnect(AppId, AppKey, loginedUserInfo.State, this.Server.UrlEncode(CallbackUrl));
        this.Response.Redirect(connect.GetAuthorizationCodeUrl("get_user_info"));

    2、新建 Notify.aspx

    Code = GetParams("code");
        State = GetParams("state");
        if (!string.IsNullOrEmpty(Code) && !string.IsNullOrEmpty(State) )
            {
                QQConnect connect = new QQConnect(AppId, AppKey, State, this.Server.UrlEncode(CallbackUrl));
                if (connect.GetAccessTokenByCode(Code) && connect.GetOpenIdByToken()
                    && !string.IsNullOrEmpty(connect.AccessToken) && !string.IsNullOrEmpty(connect.OpenId))
                {
                    string result = string.Empty;
                    QQConnect.UserInfo model = new QQConnect.UserInfo();
                    if (connect.GetUserInfo(out result, out model) && !string.IsNullOrEmpty(result) && System.String.Compare(model.ret, "0", System.StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        //业务处理和跳转
                    }
                }
            }
  • 相关阅读:
    epoll
    Neighbor Discovery Protocol Address Resolution Protocol
    text files and binary files
    cron_action
    Automation Scripts
    Toeplitz matrix
    Stolz–Cesàro theorem
    stochastic matrix
    HTTP headers with the Link header field HTTP协议支持分页(Pagination)操作,在Header中使用 Link 即可
    Markov Process
  • 原文地址:https://www.cnblogs.com/longm/p/6611775.html
Copyright © 2011-2022 走看看