 |
|
VB.NET Line Notify ส่งรูปจาก Local ไม่ขึ้นใน line ครับแก้ไขที่ตรงไหนหรอครับ |
|
 |
|
|
 |
 |
|
ตามโค๊ดเลยครับ ส่งข้อความได้ครับแต่รูปส่งไม่ไปครับ ต้องแก้ที่ตรงไหนหรอครับขอบคุณครับ
Code (VB.NET)
Public Sub sendLine(txt As String)
Chart1.SaveImage(My.Application.Info.DirectoryPath & "\charts\T201.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)
'txt & vbCrLf & "วันที่ - เวลา : " & FormatDateTime(Now(), DateFormat.GeneralDate)
Try
Dim LineMessage As String = String.Format("message={0}", txt)
Dim pictureUrl As String = My.Application.Info.DirectoryPath & "\charts\T201.jpeg"
System.Net.ServicePointManager.Expect100Continue = False
Dim Request = CType(WebRequest.Create("https://notify-api.line.me/api/notify"), HttpWebRequest)
Dim imageFile = String.Format("imageFile={0}", pictureUrl)
LineMessage += "&" + imageFile.ToString()
'// Message to Line
Dim MyData = Encoding.UTF8.GetBytes(LineMessage)
'//
Request.Method = "POST"
'// Initialize
With Request
.ContentType = "application/x-www-form-urlencoded"
.ContentLength = MyData.Length
'// Change your Token and don't cut "Bearer".
.Headers.Add("Authorization", "Bearer XXXXXXXX")
.AllowWriteStreamBuffering = True
.KeepAlive = False
.Credentials = CredentialCache.DefaultCredentials
End With
'//
Using Stream = Request.GetRequestStream()
Stream.Write(MyData, 0, MyData.Length)
End Using
Dim response = DirectCast(Request.GetResponse(), HttpWebResponse)
Dim responseString = New StreamReader(response.GetResponseStream()).ReadToEnd()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Tag : .NET, Win (Windows App), VB.NET, VS 2017 (.NET 4.x), Windows
|
|
 |
 |
 |
 |
Date :
2019-01-18 14:35:35 |
By :
realizejoke |
View :
7102 |
Reply :
21 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนด้วยนะครับ
|
 |
 |
 |
 |
Date :
2019-01-19 10:12:27 |
By :
realizejoke |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Dim imageFile = String.Format("imageFile={0}", pictureUrl)
สีแดง เป็น url หรือ เป็น stream data (base64)
ถ้าเป็น ลิงค์ หมายถีง ผู้อื่นต้องเข้าถีง ลิงค์ นี้ แต่เมื่อเป็น local ไม่แน่ใจว่า local เป็น web server หรือเปล่า
มี domain เข้าถีงหรือไม่
ดูจาก บันทัดข้างล่าง แสดงว่าเป็น path ของ window แล้ว ข้างนอกจะเข้ามาได้ยังไง ครับ
Dim pictureUrl As String = My.Application.Info.DirectoryPath & "\charts\T201.jpeg"
ทำส่งเป็น base64 แต่อ่าน document ใหม่ว่าเขาให้ส่งอะไรยังไงอีกทีนะครับ
ผมก็ไม่ได้เขียน นานแล้วไม่รู้เขาเปลี่ยนอะไรยังไง บวกความจำสั้น ลืมไปหมดแล้ว
|
 |
 |
 |
 |
Date :
2019-01-19 11:55:15 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันมี DLL ตัวนึงที่ทำให้ Line Notify image จาก local ได้นะครับ เดี๋ยวไว้ผมลองหาโปรเจ็ค TEST เก่า ๆดูครับ ตอนที่ใช้ รู้สึกไม่เกิน 10 วินาทีครับ
|
ประวัติการแก้ไข 2019-01-23 15:22:45
 |
 |
 |
 |
Date :
2019-01-23 15:19:50 |
By :
CPU4Core |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าเอาง่าย ส่งผ่าน curl ก็ได้ครับ
https://medium.com/@peeradonmekup/%E0%B8%AA%E0%B9%88%E0%B8%87-line-notify-%E0%B8%87%E0%B9%88%E0%B8%B2%E0%B8%A2%E0%B9%86%E0%B8%9A%E0%B8%99-windows-10-build-1803-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2%E0%B8%84%E0%B8%B3%E0%B8%AA%E0%B8%B1%E0%B9%88%E0%B8%87-curl-command-79d00e39ab15
https://medium.com/@dinknarf/line-notify-with-curl-c9a32730c608
|
 |
 |
 |
 |
Date :
2019-01-23 15:49:00 |
By :
fonfire |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลบให้ก่อน นะครับ ไม่รู้คนเห็นเยอะหรือยังไงก็ปรับเปลี่ยนอะไรอย่างอื่นเอาเด้อ
|
 |
 |
 |
 |
Date :
2019-01-24 00:34:09 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยหน่อยนะครับ หาวิธีแก้เท่าไรก็ไม่หาย
|
 |
 |
 |
 |
Date :
2019-01-24 18:44:25 |
By :
realizejoke |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเรียกตรง ๆ ดูครับ
ไม่ต้องสั่งผ่าน cmd
Code (VB.NET)
'เรียกใช้งาน
Dim arg As String
arg = " -X POST -H ""Authorization: Bearer FY51f34qLnSGVcdfsfsfsdfsdfsdfs"" -F ""message=TEST"" -F ""imageFile=@D:\Test.png"" https://notify-api.line.me/api/notify"
ShellandWait("curl.exe", arg)
Public Sub ShellandWait(ByVal ProcessPath As String, ByVal Arguments As String)
Dim objProcess As System.Diagnostics.Process
Try
objProcess = New System.Diagnostics.Process()
objProcess.StartInfo.Arguments = Arguments
'objProcess.StartInfo.StandardOutputEncoding = Encoding.UTF8
'objProcess.StartInfo.StandardErrorEncoding = Encoding.UTF8
objProcess.StartInfo.FileName = ProcessPath
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
objProcess.Start()
'Wait until it's finished
Application.DoEvents()
objProcess.WaitForExit()
Application.DoEvents()
'Exitcode as String
Console.WriteLine(objProcess.ExitCode.ToString())
objProcess.Close()
Catch ex As Exception
Console.WriteLine("Could not start process " & ProcessPath & " " & ex.Message.ToString)
End Try
End Sub
|
 |
 |
 |
 |
Date :
2019-01-25 08:13:34 |
By :
fonfire |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
ขอบคุณ คุณ FONFIRE มากนะครับ
เผื่อใครอยากนำไปใช้เอาไปใช้ได้เลยนะครับ
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim arg As String
arg = " -X POST -H ""Authorization: Bearer <LINE TOKEN HERE>"" -F ""message=TEST"" -F ""imageFile=@C:\charts\PIC.png"" https://notify-api.line.me/api/notify"
ShellandWait("curl.exe", arg)
End Sub
Public Sub ShellandWait(ByVal ProcessPath As String, ByVal Arguments As String)
Dim objProcess As System.Diagnostics.Process
Try
objProcess = New System.Diagnostics.Process()
objProcess.StartInfo.Arguments = Arguments
objProcess.StartInfo.FileName = ProcessPath
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
objProcess.Start()
Application.DoEvents()
objProcess.WaitForExit()
Application.DoEvents()
Console.WriteLine(objProcess.ExitCode.ToString())
objProcess.Close()
Catch ex As Exception
MsgBox("Could not start process " & ProcessPath & " " & ex.Message.ToString)
End Try
End Sub
|
ประวัติการแก้ไข 2019-01-25 09:29:36
 |
 |
 |
 |
Date :
2019-01-25 09:29:09 |
By :
realizejoke |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนผู้รู้ด้วยนะคะ ไม่รู้จะทำยังไง ให้สามารถ ส่งข้อความจากเครื่องไปที่ line ได้

|
 |
 |
 |
 |
Date :
2019-06-21 22:30:44 |
By :
malee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดูตัวอย่าง คห 19 เขาเอาโค๊ดมาลงยังไง เขามีเครื่องไม้เครื่องมือให้ใช้ เพื่อความสดวก คนที่จะช่วยก็ง่ายในการก๊อปปี้มาแก้ไขให้
มาเป็นภาพขี้เกียจพิมพ์เอง
|
 |
 |
 |
 |
Date :
2019-06-23 07:58:47 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|