Created
June 29, 2019 11:50
-
-
Save the-takeo/21930f63c097b0a33f4b20dd9a6ea0c3 to your computer and use it in GitHub Desktop.
LineNotify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace LineNotifyForFamily | |
{ | |
public static class LineNotify | |
{ | |
static string token = "Your Token"; | |
public static void SendMessage(string message) | |
{ | |
var result = sendMessage(message); | |
result.Wait(); | |
} | |
private static async Task sendMessage(string message) | |
{ | |
using (var client = new HttpClient()) | |
{ | |
var content = new FormUrlEncodedContent(new Dictionary<string, string> | |
{ | |
{ "message", message }, | |
}); | |
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); | |
var result = await client.PostAsync("https://notify-api.line.me/api/notify", content); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment