根據line 所提供的API 文件
https://notify-bot.line.me/doc/en/
試了幾天終於成功了
1.準備圖檔
網路上擷取的圖片存於D:\
2.
using System.Net.Http; //Call API
using System.IO; //讀檔
3
private void button2_Click(object sender, EventArgs e)
{
try
{
var file = @"D:\2324.jpg"; //圖檔位置
var upfilebytes = File.ReadAllBytes(file);
HttpClientHandler handler = new HttpClientHandler();
HttpClient Client = new HttpClient(handler);
Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "mxbYX3GTvB1H"); //Token
MultipartFormDataContent content = new MultipartFormDataContent();
ByteArrayContent baContent = new ByteArrayContent(upfilebytes);
content.Add(baContent, "imageFile", "2324.jpg");
string url = @"https://notify-api.line.me/api/notify?message="; //組訊息
url = url + textBox1.Text.ToString();
var response =Client.PostAsync(url, content).Result;
}
catch(Exception ex)
{
}
}
4.測試
------------------------------------------------------------------------------------------------------------------------------------
哇...........要結束服務了
留言列表