智能AI代码工具Cursor的使用

发布时间 2023-04-04 16:30:24作者: 向萧

 

 

// Import necessary namespaces
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

// Define a method to send a message to the WeChat group
public async Task SendMessageToWeChatGroup(string message)
{
    // Define the WeChat group webhook URL
    string weChatGroupWebhookUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY_HERE";

    // Define the message payload
    string payload = "{\"msgtype\": \"text\", \"text\": {\"content\": \"" + message + "\"}}";

    // Create a new HTTP client
    using (HttpClient client = new HttpClient())
    {
        // Create a new StringContent object with the message payload
        StringContent content = new StringContent(payload, Encoding.UTF8, "application/json");

        // Send a POST request to the WeChat group webhook URL with the message payload
        HttpResponseMessage response = await client.PostAsync(weChatGroupWebhookUrl, content);

        // Check if the response was successful
        if (response.IsSuccessStatusCode)
        {
            // Log a success message
            Console.WriteLine("Message sent successfully to WeChat group!");
        }
        else
        {
            // Log an error message
            Console.WriteLine("Error sending message to WeChat group: " + response.StatusCode);
        }
    }
}

学无止境  未来已来