Tweet an image with Text with Node Red

299 views
Skip to first unread message

Olivier Denis

unread,
Sep 21, 2017, 6:48:25 AM9/21/17
to Node-RED
Bonjour
i want to send with node red a tweet that it contains a text with an image. The text and the image can't be the same.
I didi test with image and it is OK, the same with a text, but i didn't find for the moment the solution to send a tweet with image and text.
Have you a solution ? a flow sample ?
Thanks
Olivier
Ps : sorry for my english

Mark Setrem

unread,
Sep 21, 2017, 7:20:33 AM9/21/17
to Node-RED
If you can post your flow it is easier to see where you are going wrong.

Olivier Denis

unread,
Sep 21, 2017, 10:46:36 AM9/21/17
to Node-RED
Bonjour

below my flow, I hope that  it help you. I just want to put a dynamic message with my photo. I don't know how i must give the message to the tweet box.

Thanks

[
    {
        "id": "de2cb13d.ae6f8",
        "type": "tab",
        "label": "Flow 1"
    },
    {
        "id": "cd5caaaa.1c3eb8",
        "type": "file in",
        "z": "de2cb13d.ae6f8",
        "name": "M238.png",
        "filename": "C:\\Program Files (x86)\\Schneider Electric\\SoMachine Basic\\CatalogResources\\Images\\M238.png",
        "format": "",
        "x": 570,
        "y": 547,
        "wires": [
            [
                "5444605.dc7bc2"
            ]
        ]
    },
    {
        "id": "5104ecb.1581914",
        "type": "inject",
        "z": "de2cb13d.ae6f8",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 348,
        "y": 530,
        "wires": [
            [
                "cd5caaaa.1c3eb8",
                "fc8e5aad.66e2b8"
            ]
        ]
    },
    {
        "id": "18ad7856.e67c6",
        "type": "twitter out",
        "z": "de2cb13d.ae6f8",
        "twitter": "",
        "name": "Tweet",
        "x": 1157,
        "y": 586,
        "wires": []
    },
    {
        "id": "894e6551.b9216",
        "type": "function",
        "z": "de2cb13d.ae6f8",
        "name": "",
        "func": "node.log(\"M238.png\");\nvar FileName=\"C:\\\\Program Files (x86)\\\\Schneider Electric\\\\SoMachine Basic\\\\CatalogResources\\\\Images\\\\M238.png\";\nnode.log(FileName);\n//msg.media = new Buffer(FileName);\nmsg.media = new Buffer(FileName, 'base64');\nmsg.payload =\"Mon message\";\n//C:\\Program Files (x86)\\Schneider Electric\\SoMachine Basic\\CatalogResources\\Images\\M238.png\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 615,
        "y": 348,
        "wires": [
            [
                "18ad7856.e67c6"
            ]
        ]
    },
    {
        "id": "dbceab81.942ca8",
        "type": "inject",
        "z": "de2cb13d.ae6f8",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 344,
        "y": 340,
        "wires": [
            [
                "894e6551.b9216"
            ]
        ]
    },
    {
        "id": "5444605.dc7bc2",
        "type": "change",
        "z": "de2cb13d.ae6f8",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "media",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "flow",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 782,
        "y": 610,
        "wires": [
            [
                "18ad7856.e67c6"
            ]
        ]
    },
    {
        "id": "fc8e5aad.66e2b8",
        "type": "function",
        "z": "de2cb13d.ae6f8",
        "name": "",
        "func": "msg.payload =\"toto et tata\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 560,
        "y": 634,
        "wires": [
            [
                "5444605.dc7bc2"
            ]
        ]

Mark Setrem

unread,
Sep 21, 2017, 11:25:45 AM9/21/17
to Node-RED
OK, you can't split and rejoin flow paths like that. You would need to either use other nodes to split or join the flow, or alternatively make the flow linear.

Here's a version that works for me...

[{"id":"8b205eaa.f1117","type":"inject","z":"c17973be.edb23","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"x":348,"y":530,"wires":[["d21df200.72fba"]]},{"id":"564af40c.bab1e4","type":"twitter out","z":"c17973be.edb23","twitter":"","name":"Tweet","x":1157,"y":586,"wires":[]},{"id":"cb823780.789d08","type":"change","z":"c17973be.edb23","name":"","rules":[{"t":"set","p":"media","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":782,"y":610,"wires":[["e45db11b.f8a448"]]},{"id":"e45db11b.f8a448","type":"function","z":"c17973be.edb23","name":"","func":"msg.payload =\"toto et tata\";\nreturn msg;","outputs":1,"noerr":0,"x":983,"y":597,"wires":[["564af40c.bab1e4"]]},{"id":"d21df200.72fba","type":"file in","z":"c17973be.edb23","name":"M238.png","filename":"C:\\Program Files (x86)\\Schneider Electric\\SoMachine Basic\\CatalogResources\\Images\\M238.png","format":"","x":547,"y":565,"wires":[["cb823780.789d08"]]}]

Olivier Denis

unread,
Sep 22, 2017, 5:30:38 AM9/22/17
to node...@googlegroups.com
Merci Mark,
Thanks, it is very easy..after you give me the solution :-)
Thanks


--
http://nodered.org

Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/QdyZWMJEOcU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send an email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/7b76869f-89cd-43aa-8948-a3b3f87d11a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages