private void button1_Click(object sender, EventArgs e)
{
try
{
webBrowser1.Navigate("https://www.fast2sms.com/dev/wallet?authorization=[API KEY]&sender_id=FSTSMS&message='"+textBox2.Text+"'&route=p&numbers='"+textBox1.Text+"'");
}
catch (Exception ex)
{
}
}
我需要通过FAST2SMS使用C#Windows应用程序发送短信
我正在c#中使用Web浏览器工具进行导航,
答案 0 :(得分:0)
示例取自.NET Docs。从.Net 4.5开始,HttpClient可用,它也是NetStandard的一部分
static async Task Main()
{
// Create a New HttpClient object.
HttpClient client = new HttpClient();
// Call asynchronous network methods in a try/catch block to handle exceptions
try
{
HttpResponseMessage response = await client.GetAsync("http://www.contoso.com/");
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
// Above three lines can be replaced with new helper method below
// string responseBody = await client.GetStringAsync(uri);
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
// Need to call dispose on the HttpClient object
// when done using it, so the app doesn't leak resources
client.Dispose(true);
}