close

根據line 所提供的API 文件

https://notify-bot.line.me/doc/en/

Line Notify send local image C

Line Notify send local image C

試了幾天終於成功了

1.準備圖檔

網路上擷取的圖片存於D:\

Line Notify send local image CLine Notify send local image C

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.測試

Line Notify send local image C

Line Notify send local image C

 

------------------------------------------------------------------------------------------------------------------------------------

哇...........要結束服務了

Line Notify send local image C

arrow
arrow
    文章標籤
    c# linenotify line
    全站熱搜
    創作者介紹
    創作者 JosephChou 的頭像
    JosephChou

    Joseph A-Sa-BLue

    JosephChou 發表在 痞客邦 留言(1) 人氣()