首页 > 其他分享 >模拟腾讯返回的json数据

模拟腾讯返回的json数据

时间:2022-10-28 17:59:18浏览次数:55  
标签:info authorizer string json alert token 腾讯 queryAuthResultEntity 模拟

 模拟腾讯返回的json数据

 

$(document).ready(function () {
                    $("#SubmitButton").click(function () {
                        alert("ajax准备开始");
                        var wxJson = {
                            "authorization_info": {
                                "authorizer_appid": "wxf8b4f85f3a794e77",
                                "authorizer_access_token": "QXjUqNqfYVH0yBE1iI_7vuN_9gQbpjfK7hYwJ3P7xOa88a89-Aga5x1NMYJyB8G2yKt1KCl0nPC3W9GJzw0Zzq_dBxc8pxIGUNi_bFes0qM",
                                "expires_in": 7200,
                                "authorizer_refresh_token": "dTo-YCXPL4llX-u1W1pPpnp8Hgm4wpJtlR6iV0doKdY",
                                "func_info": [
                                {
                                    "funcscope_category": {
                                        "id": 3
                                    }
                                },
                                {
                                    "funcscope_category": {
                                        "id": 2
                                    }
                                },
                                {
                                    "funcscope_category": {
                                        "id": 4
                                    }
                                }
                                ]
                            }
                        };
                      var fff=  JSON.stringify(wxJson);
                        var objAAA = "";
                        $.ajax({                         
                            url: "/SysClient/BusinessWxAuthorizationTest1/OAuthCallbackTest1.aspx",
                            data: {
                                wxJson: fff,
                                auth_code: "123kkk",                                                               
                            },
                            //dataType: "json",
                            success: function (obj) {
                                alert(obj);

                                objAAA = eval('(' + obj + ')');                 
                                if (objAAA.code == "1") {
                                    alert("成功"); 
                                    alert(objAAA.data.redirectUrl);
                                    return;
                                }
                                else if (objAAA.code == "0") {
                                    alert("服务器返回来一个失败,请检查语句。" + obj.msg);
                                    return;
                                }
                                alert("成功了,返回:" + obj);
                                return;
                            },
                            error: function () {
                                alert("程序失败了,请调试检查");
                            }
                        })
                        alert("ajax完成");
                    })
                })

//---------------------------------------------------------------------------------------------------------

protected void Page_Load(object sender, EventArgs e)
        {
            //模拟腾讯返回数据,进行处理
            string wxJson = Request["wxJson"];
            //string auth_code = Request["auth_code"];

            //授权方appid
            string authorizer_appid = string.Empty;
            //授权方接口调用凭据
            string authorizer_access_token = string.Empty;
            //有效期(在授权的公众号或小程序具备API权限时,才有此返回值)
            int expires_in;
            //接口调用凭据刷新令牌
            string authorizer_refresh_token = string.Empty;

            StringBuilder sb = new StringBuilder();
            var queryAuthResultEntity = ResultJsonHelper.GetResult<QueryAuthResult>(wxJson);
            authorizer_appid = queryAuthResultEntity.authorization_info.authorizer_appid;
            authorizer_access_token = queryAuthResultEntity.authorization_info.authorizer_access_token;
            expires_in = queryAuthResultEntity.authorization_info.expires_in;
            authorizer_refresh_token = queryAuthResultEntity.authorization_info.authorizer_refresh_token;

            foreach (var item in queryAuthResultEntity.authorization_info.func_info)
            {
                var idInt = (int)item.funcscope_category.id;
                sb.Append(idInt + ",");
            }
            string sbStr = sb.ToString().Substring(0, sb.ToString().Length - 1);

        }

 

搜索

复制

标签:info,authorizer,string,json,alert,token,腾讯,queryAuthResultEntity,模拟
From: https://www.cnblogs.com/jankie1122/p/11108724.html

相关文章

  • 腾讯返回json数据转换
     腾讯返回json数据转换 #region----远程获取微信小程序二维码的流----///<summary>///远程获取微信小程序二维码的流///</summary>......
  • C#对象转json
     objectobj=new{Provider=appointmentErpStoreEntity.ProvinceName,City=appointmen......
  • C#后端接收前端json数组
    C#后端接收前端json数组方案一:///<summary>///(APP端)查询购物车选中商品的总价///</summary>publicclassCartTotalPriceRequestDto{/......
  • 浅析package.json
    package.json用来描述项目及项目所依赖的模块信息。全文以npm为例package.json与package-lock.json的关系版本指定~会匹配最近的小版本依赖包,比如~1.2.......
  • postman +腾讯电子签
      postman.setGlobalVariable("Timestamp",Date.parse(newDate())/1000);postman.setGlobalVariable("Nonce",Date.parse(newDate())/1000);//正式环境//......
  • js对象封装 Json字符
    不废话直接上代码:functionobjUserNickName(UserName,NickName){this.UserName=UserName;this.NickName=NickName;}objuser1=newobjUserNickName();objuser......
  • selenium模拟登录使用https协议的网址时报错的解决方法
    公司的测试地址是https协议的,使用使用默认的selenium登录时会出现安全提示的报错,导致无法模拟自动化。对此,笔者通过网上查找资料和实践,发现只需要简单的修改一下浏览器驱......
  • notepad++格式化json
    1、JsonView插件地址:https://百度网盘/s/11LJU_9ZI0H5TUOPMbE7jRg   验证码:rsjk​2、使用插件把插件放入到notepad++的安装目录下的plugin下3、使用notepad++格式化json......
  • dotnet6使用System.Text.Json替代Newtonsoft.Json
    HowtoserializeanddeserializeJSONusingC#-.NET|MicrosoftLearn //序列化和反序列号范例usingSystem.Text.Json;usingSystem.Text.Encodings.Web;usin......
  • Newtonsoft.Json将可空类型转换为空字符串(支持所有类型)
    第一步:json自定义解析协议///<summary>///json自定义解析协议///</summary>publicclassSpecialJsonContractResolver:DefaultContractResolve......