Skip to content

Instantly share code, notes, and snippets.

@jackrobotics
Created December 19, 2017 21:19
Show Gist options
  • Save jackrobotics/ff6753556c9b81ab8ef2ba72e2fa305a to your computer and use it in GitHub Desktop.
Save jackrobotics/ff6753556c9b81ab8ef2ba72e2fa305a to your computer and use it in GitHub Desktop.
private void lineNotify(string msg)
{
string token = "9IBnp37LVHj0a6W5HLq2dF7sqIjGyEVn2DQtpQq7wYv";
try
{
var request = (HttpWebRequest)WebRequest.Create("https://notify-api.line.me/api/notify");
var postData = string.Format("message={0}", msg);
var data = Encoding.UTF8.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
request.Headers.Add("Authorization", "Bearer "+token);
using (var stream = request.GetRequestStream())stream.Write(data, 0, data.Length);
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment