![]() |
Send image from IP camera to Telegram - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Send image from IP camera to Telegram (/showthread.php?tid=2792) Pages:
1
2
|
Send image from IP camera to Telegram - peyoe - 13.08.2020 I have an IP camera working and I can view it trough my logic machine. The next step I like to reach is to send the snapshot to my telegram. I have already configured my telegram, I can send messages. But it's impossible to send a snapshot. I have a DAHUA camera, and the url to view the snapshot is this: Http: // user: password@cameraip/cgi-bin/snapshot.cgi I can view it in chrome without problems. I try to send it with "sendphoto" command and with the example from here, in this case send through email. https://forum.logicmachine.net/showthread.php?tid=1061 I do not know what else to do. Can someone help me? Thanks. RE: Send image form ip camera to telegram - admin - 13.08.2020 First you need to retrieve the image using http request. Then you can send the image using this example. filedata variable must contain image data as a string, change PUT_CHAT_ID_HERE and PUT_BOT_TOKEN_HERE placeholders Code: require('ssl.https') RE: Send image form ip camera to telegram - peyoe - 13.08.2020 Thanks for the answer. I put my url snapshot on "filedata" and my CHATID and BOT_TOKEN, but it doesn't work. The log says: * arg: 1 * number: 1 * arg: 2 * number: 400 * arg: 3 * table: ["server"] * string: nginx/1.16.1 ["access-control-expose-headers"] * string: Content-Length,Content-Type,Date,Server,Connection ["content-type"] * string: application/json ["connection"] * string: close ["content-length"] * string: 79 ["date"] * string: Thu, 13 Aug 2020 15:18:09 GMT ["strict-transport-security"] * string: max-age=31536000; includeSubDomains; preload ["access-control-allow-origin"] * string: * * arg: 4 * string: HTTP/1.1 400 Bad Request * string: {"ok":false,"error_code":400,"description":"Bad Request: IMAGE_PROCESS_FAILED"} RE: Send image form ip camera to telegram - admin - 13.08.2020 As mentioned before first you need to retrieve the image from your camera via http request. You cannot pass a url to the snapshot here because telegram server cannot access your camera. RE: Send image form ip camera to telegram - peyoe - 13.08.2020 Ok. As you can see I'm a completely noob with LUA. I will search info about that. Thanks again. RE: Send image form ip camera to telegram - peyoe - 14.08.2020 Hello. I have tried to retrieve the image with no results. I have used these examples: https://forum.logicmachine.net/showthread.php?tid=1630&highlight=image+http+request https://forum.logicmachine.net/showthread.php?tid=1061&pid=9364#pid9364 Can you explain me how I need to do this? Thanks in advance. RE: Send image form ip camera to telegram - admin - 14.08.2020 Log what you get when sending a request to the camera. Make sure that the URL is correct and it actually returns an image not a HTML page containing the image. Code: require('socket.http') RE: Send image form ip camera to telegram - peyoe - 14.08.2020 (14.08.2020, 08:08)admin Wrote: Log what you get when sending a request to the camera. Make sure that the URL is correct and it actually returns an image not a HTML page containing the image. Sure: * arg: 1 * string: * arg: 2 * number: 401 * arg: 3 * table: ["content-length"] * string: 0 ["www-authenticate"] * string: Digest realm="Login to 5L02EC8PAGC1BC0", qop="auth", nonce="762101674", opaque="e65481894c6ae41a2f1296db7e53d66882f66471" ["connection"] * string: close * arg: 4 * string: HTTP/1.1 401 Unauthorized RE: Send image form ip camera to telegram - admin - 14.08.2020 This means that you need to use digest code example from here: https://forum.logicmachine.net/showthread.php?tid=1061&pid=9364#pid9364 log what you get from the request: Code: url = 'http://user:password@cameraip/cgi-bin/snapshot.cgi' RE: Send image form ip camera to telegram - peyoe - 14.08.2020 (14.08.2020, 08:47)admin Wrote: This means that you need to use digest code example from here: https://forum.logicmachine.net/showthread.php?tid=1061&pid=9364#pid9364 With the last code I have not had any records, instead that I had an error: User script:21: attempt to call global 'request' (a nil value) stack traceback: User script:21: in main chunk RE: Send image form ip camera to telegram - admin - 14.08.2020 You need to copy the whole code from here: https://forum.logicmachine.net/showthread.php?tid=1061&pid=9364#pid9364 And change the last lines as in my previous post. RE: Send image form ip camera to telegram - peyoe - 14.08.2020 (14.08.2020, 08:53)admin Wrote: You need to copy the whole code from here: https://forum.logicmachine.net/showthread.php?tid=1061&pid=9364#pid9364 Ok, sorry. This is the log: Code: * arg: 1 RE: Send image form ip camera to telegram - peyoe - 14.08.2020 EDIT It's working, I have to put on filedata, the name without ' '. Thanks admin. This is my whole code: Code: local skthttp = require('socket.http') RE: Send image form ip camera to telegram - admin - 14.08.2020 This line is incorrect: Code: filedata = 'image' It should be Code: filedata = image RE: Send image form ip camera to telegram - peyoe - 14.08.2020 (14.08.2020, 11:08)admin Wrote: This line is incorrect: Yes, I just put it in my previous post. Thank you very much again. RE: Send image form ip camera to telegram - AlphaAI - 23.07.2025 (14.08.2020, 11:08)admin Wrote: This line is incorrect: Hello, I have tried the above methods but still cannot receive images on Telegram. Below is the log result after running resident script: Code: * arg: 1 RE: Send image form ip camera to telegram - admin - 23.07.2025 The error comes from the camera. Check if username and password are correct. Then check the documentation, the snapshot URL might be different or some option must be enabled first for snapshots to work. RE: Send image form ip camera to telegram - AlphaAI - 25.07.2025 (23.07.2025, 13:16)admin Wrote: The error comes from the camera. Check if username and password are correct. Then check the documentation, the snapshot URL might be different or some option must be enabled first for snapshots to work. I copied the URL from the code into Chrome, and it successfully returned a snapshot, so where could the issue be? RE: Send image form ip camera to telegram - admin - 25.07.2025 It works in browser because you are already authenticated. Change url variable as needed, run this script once and post what you get in Logs tab: Code: url = 'http://USER:PASS@CAM_IP...' RE: Send image form ip camera to telegram - AlphaAI - 25.07.2025 (25.07.2025, 06:44)admin Wrote: It works in browser because you are already authenticated. Here is what I got. Code: * arg: 1 |