ASP.NET MVC卷曲等效
发布时间:2020-12-16 06:25:55 所属栏目:asp.Net 来源:网络整理
导读:我很难找到很多细节.我需要使用处理信用卡的api并使用curl.所有文档都在php中,虽然我可以使用php,但我的主站点完全是使用razor视图引擎的MVC4.我需要将这个从 PHP转换为.net中可用的东西 $curl https://api.stripe.com/v1/customers -u *private key here*:
我很难找到很多细节.我需要使用处理信用卡的api并使用curl.所有文档都在php中,虽然我可以使用php,但我的主站点完全是使用razor视图引擎的MVC4.我需要将这个从
PHP转换为.net中可用的东西
$curl https://api.stripe.com/v1/customers -u *private key here*: -d "description=Customer for test@example.com" -d "card[number]=4242424242424242" -d "card[exp_month]=12" -d "card[exp_year]=2013" 在此先感谢您的时间 解决方法
从
curl manual页面
> -u,– user< user:password>是用户凭据 所以你可以“解码”这个: using (var wc = new System.Net.WebClient()) { // data string parameters = string.Concat("description=",description,"&card[number]=",cardNumber,"&card[exp_month]=",cardExpirationMonth,"&card[exp_year]=",cardExpirationYear),url = "https://api.stripe.com/v1/customers; // let's fake it and make it was a browser requesting the data wc.Headers.Add("user-agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); // credentials wc.Credentials = new System.Net.NetworkCredential("*private key here*",""); // make it a POST instead of a GET wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; // send and get answer in a string string result = wc.UploadString(url,parameters); } 更新了existing answer的POST调整. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 部署 – kestrel-hellomvc.service:步骤USER产生失败/usr/
- asp.net-mvc – 为什么LINQ to Entities不能识别方法’Syst
- asp.net中使用自定义控件的方式实现一个分页控件的代码
- asp-classic – 经典ASP:捕获错误
- 获取ASP.Net中的当前应用程序虚拟路径
- ASP.NET成员提供程序 – 单一登录
- asp.net-mvc – 是否可以使用自定义错误页面与MVC网站,但不
- 有没有人使用ASP.net(webforms)动态生成javascript和/或css
- ASP.NET主页面和内容页面中的表单元素
- asp.net – 在IE7 / IE8中未定义window.XMLHttpRequest
推荐文章
站长推荐
- asp.net-mvc – MVC中部分VIEW和用户控件的区别
- asp.net-mvc – 在ASP.NET MVC应用程序中实现细粒
- asp.net-mvc – 当ASP.NET 5(vNext)无法重定向绑
- .net – 为每个操作设置MaxAllowedContentLength
- asp.net – 会话状态在ajax帖子之间丢失了吗?
- asp.net-mvc – MVC 4安装失败
- asp.net – ‘Sys.WebForms.PageRequestManager’
- 删除ASP.NET MVC 4路由到应用程序根目录中的尾随
- asp.net – WebApi:将参数映射到标头值
- asp.net – 如何根据用户角色启用和禁用按钮?
热点阅读