Exemplo n.º 1
0
        internal static WebCredential GetCredential(string appId, string appSecret, string code)
        {
            WebCredential cred = null;

            var json = Util.HttpGet2(string.Format(TokenUrl, appId, appSecret, code));
            if (json.IndexOf("errcode") >= 0)
            {
                cred = new WebCredential();
                cred.error = Util.JsonTo<ReturnCode>(json);
            }
            else
            {
                cred = Util.JsonTo<WebCredential>(json);
                cred.add_time = DateTime.Now;
            }
            return cred;
        }
Exemplo n.º 2
0
        internal static WebCredential GetCredential(string appId, string appSecret, string code)
        {
            WebCredential cred = null;

            var json = Util.HttpGet2(string.Format(TokenUrl, appId, appSecret, code));

            if (json.IndexOf("errcode") >= 0)
            {
                cred       = new WebCredential();
                cred.error = Util.JsonTo <ReturnCode>(json);
            }
            else
            {
                cred          = Util.JsonTo <WebCredential>(json);
                cred.add_time = DateTime.Now;
            }
            return(cred);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 通过code换取网页授权access_token
 /// </summary>
 /// <param name="appId"></param>
 /// <param name="appSecret"></param>
 /// <param name="code"></param>
 /// <returns></returns>
 public static WebCredential GetWebAccessToken(string appId, string appSecret, string code)
 {
     return(WebCredential.GetCredential(appId, appSecret, code));
 }