加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 从后面的代码发出http请求

发布时间:2020-12-15 23:57:36 所属栏目:百科 来源:网络整理
导读:我正在尝试实施 Message API 我不确定我将如何从代码隐藏和它们的代码片段中调用它,它说: https://platform.3cinteractive.com/api/send_message.php POSTusername=aRDSe3vcaMzh06YrMcxcQw==password=1BSvQc6lpNlnp4ufWgRLPHNJ7RMrL8CcaWCzL1Vtw+Y=phone_nu
我正在尝试实施 Message API

我不确定我将如何从代码隐藏和它们的代码片段中调用它,它说:

https://platform.3cinteractive.com/api/send_message.php 

POST
username=aRDSe3vcaMzh06YrMcxcQw==&password=1BSvQc6lpNlnp4ufWgRLPHNJ7RMrL8CcaWCzL1Vtw+Y=&phone_number=+11234567890&trigger_id=1105&message=howdy

解决方法

使用下面的 WebRequest类或使用像 RestSharp这样的库来获得更多控制或HTTP请求:

// Create a request for the URL.        
WebRequest request = WebRequest.Create ("http://www.contoso.com/default.html");
// If required by the server,set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
// Display the status.
Console.WriteLine (response.StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream ();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader (dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd ();
// Display the content.
Console.WriteLine (responseFromServer);
// Cleanup the streams and the response.
reader.Close ();
dataStream.Close ();
response.Close ();

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读