Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C点击电话发送短信HTTP GET请求_C#_Winforms_Httpwebrequest - Fatal编程技术网

C# C点击电话发送短信HTTP GET请求

C# C点击电话发送短信HTTP GET请求,c#,winforms,httpwebrequest,C#,Winforms,Httpwebrequest,我想使用Clickatell服务发送一条简单的消息 我不想阅读回复,发送消息的请求很简单 服务提供的请求如下所示: https://platform.clickatell.com/messages/http/send?apiKey=xxxxxxxxxxxxxxxx==&to=xxxxxxxxxxx&content=Test+message+text 我用卷发检查了一下 curl "https://platform.clickatell.com/messages/http/sen

我想使用Clickatell服务发送一条简单的消息

我不想阅读回复,发送消息的请求很简单

服务提供的请求如下所示:

https://platform.clickatell.com/messages/http/send?apiKey=xxxxxxxxxxxxxxxx==&to=xxxxxxxxxxx&content=Test+message+text
我用卷发检查了一下

curl "https://platform.clickatell.com/messages/http/send?apiKey=apiKEY==&to=NUMBER&content=Test+message+text"
而且它工作得很好

我尝试将它与带有HTTP请求的Windows窗体应用程序一起使用 以下是我提供的代码:

var client2 = new HttpClient();
client2.GetAsync("https://platform.clickatell.com/messages/http/send?apiKey=apiKEY==&to=NUMBER&content=Test+message+text");
App.Write("SMS SEND!");
我有短信发送的信息,但我没有收到。我的朋友在.NET应用程序中使用我的代码,它对他有效

我错过什么了吗

也许值得一提的是,我需要使用System.Net.Http手动添加到引用中

编辑:

我尝试添加以异步执行,因此我将代码编辑为:

   static void sendSMS()
        {
            var client2 = new HttpClient();
            var task = client2.GetAsync("https://platform.clickatell.com/messages/http/send?apiKey=API_KEY==&to=MY_NUMBER&content=Test+message+text");
            task.Wait();
            App.Write("SMS SEND!");
        }

但是现在应用程序中的SMS发送消息没有显示。

好的,我知道您使用的是.NET 4.5,您可能有一个exeption问题

基础连接已关闭:发送时发生意外错误

正确的代码如下所示:您必须在请求之前添加“SecurityProtocol”:

ServicePointManager.SecurityProtocol=SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12

var client2=新的HttpClient; client2.GetAsynchttps://platform.clickatell.com/messages/http/send?apiKey=apiKEY==&to=NUMBER&content=Test+message+text.Result;


这里有更多详细信息

我知道您不想长期阅读回复,但为了测试并使其正常工作,也许您应该这样做