asp.net备用卷曲URI [英] asp.net alternate to curl uri

查看:107
本文介绍了asp.net备用卷曲URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是替代在asp.net下面卷曲URI

 卷曲-u MyUserName输入:MyPassword输入http://api.messaging.staging.voxeo.net/1.0/messaging-X POST -d \"botkey=12345&apimethod=send&msg=My%20test%20message.&user=14075555555&network=SMS&from=14076666666\"

URI部分是容易的,但如何添加用户名和密码,因为我需要设置一些这方面的HTTP头象下面

  curl_setopt($ CH,CURLOPT_HEADER,0); $data=\"botkey=\".$botkey.\"&apimethod=send&msg=\".$msg.\"&userkey=\".$userKey.\"&network=SMS&from=\".$from;
 这是一个设置用户名密码
curl_setopt($ CH,CURLOPT_USERPWD,'[演化用户名]:[进化密码]');


解决方案

您可以使用的 HttpWebRequest的或的 WebClient的归类到与其他网站进行交互。鉴于您的使用情况似乎有点复杂/具体的我会建议的HttpWebRequest

您可以使用证书财产分配您的用户名/密码凭据和标题属性来添加自定义的头。

<一个href=\"http://stackoverflow.com/questions/4699938/how-to-download-the-file-using-httpwebrequest-and-httpwebresponse-classcookies\">This SO问题有样品code。请注意,您应该处置您的Htt prequest对象正确,以及他们访问非托管资源。

What would be alternative in asp.net for below curl uri

curl -u MyUserName:MyPassword "http://api.messaging.staging.voxeo.net/1.0/messaging" -X POST -d "botkey=12345&apimethod=send&msg=My%20test%20message.&user=14075555555&network=SMS&from=14076666666"

URI part is easy but how do i add username and password as i need to set some http headers for this like following

curl_setopt($ch, CURLOPT_HEADER, 0);

 $data="botkey=".$botkey."&apimethod=send&msg=".$msg."&userkey=".$userKey."&network=SMS&from=".$from;
 HERE IT IS SETTING USERNAME PASSWORD
curl_setopt($ch, CURLOPT_USERPWD, '[Evolution User Name]:[Evolution Password]');

解决方案

You can use the HttpWebRequest or WebClient classed to interact with other sites. Given your use case seems a little more complicated/specific I would recommend HttpWebRequest.

You can use the Credentials property to assign your Username/Password credentials and the Header property to add your custom headers.

This SO Question has sample code. Do note that you should dispose of your HttpRequest objects correctly as well as they access unmanaged resources.

这篇关于asp.net备用卷曲URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆