C#跨平台调用接口(URL传参GET调用和Post Json传参调用)

方法一:URL传参Get调用

使用HttpWebRequest,将参数Get调用


  string HampsonURL = new BSysConfig().GetValue(ConfigKey.接口地址);
                HampsonInfo Hmodel = new HampsonInfo();
                Hmodel.cname = ePersonInfo.Name;
                Hmodel.cmobile = ePersonInfo.Mobile;
                Hmodel.cage = ePersonInfo.Age.ToString();
                Hmodel.ccity = ePersonInfo.IntentCity;
                Hmodel.user = "8a9ea098ac0079426ae3c722c8e48d0d";
                string url = string.Format(@"{0}?user={1}&cname={2}&cmobile={3}&cage={4}&ccity={5}"
                           , HampsonURL, Hmodel.user, Hmodel.cname, Hmodel.cmobile, Hmodel.cage, Hmodel.ccity);
                try
                {
                    string resultCode = GetHttp(url, 100000);
                    switch (Convert.ToInt32(resultCode))
                    {
                        case 0:
                            result = "录入成功";
                            break;
                        case 1:
                            result = "此用户已存在";
                            break;
                        case 2:
                            result = "其他错误";
                            break;
                        default:
                            result = "文档木有写是啥错";
                            break;
                    }
    &n

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值