Created
December 19, 2017 21:19
-
-
Save jackrobotics/ff6753556c9b81ab8ef2ba72e2fa305a to your computer and use it in GitHub Desktop.
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
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