Sending Json data in PHP url to WhatsAPP

Hi ,

I am trying to send json data in API WhatsApp. But unsuccessful
https://api.callmebot.com/whatsapp.php?phone=+6XXXXXXXXX&text={{payload}}&apikey=XXXXX
json = {"name":"pippo","surname":"topolino","street":"blablabla"}

Thank you

[{"id":"f41d6585.b46bc8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"d47cff11.4fdcb","type":"inject","z":"f41d6585.b46bc8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"name\":\"pippo\",\"surname\":\"topolino\",\"street\":\"blablabla\"}","payloadType":"json","x":220,"y":120,"wires":[["4bfb653b.bda82c"]]},{"id":"4bfb653b.bda82c","type":"http request","z":"f41d6585.b46bc8","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://api.callmebot.com/whatsapp.php?phone=+6XXXXXXXXX&text={{payload}}&apikey=XXXXX","tls":"","persist":false,"proxy":"","authType":"","x":470,"y":120,"wires":[["15350927.8b8307"]]},{"id":"15350927.8b8307","type":"debug","z":"f41d6585.b46bc8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":120,"wires":[]}]

I would think you would need to convert the object to a string, then uri encode the string. At the whats app end I am not sure it would display correctly as I do not use WhatsApp.

example encoding 2 methods you could use change node or function node.

[{"id":"95161356.faf46","type":"json","z":"c74669a0.6a34f8","name":"","property":"payload","action":"str","pretty":false,"x":210,"y":920,"wires":[["7c3de8f6.f3f8a8"]]},{"id":"e6a73fa4.f68508","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"name\":\"pippo\",\"surname\":\"topolino\",\"street\":\"blab labla\"}","payloadType":"json","x":110,"y":920,"wires":[["95161356.faf46"]]},{"id":"7c3de8f6.f3f8a8","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$encodeUrlComponent(payload)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":940,"wires":[["4881fc5b.fb3614"]]},{"id":"4881fc5b.fb3614","type":"http request","z":"c74669a0.6a34f8","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://api.callmebot.com/whatsapp.php?phone=+6XXXXXXXXX&text={{payload}}&apikey=XXXXX","tls":"","persist":false,"proxy":"","authType":"","x":580,"y":940,"wires":[["97b644a3.4e235"]]},{"id":"97b644a3.4e235","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":900,"wires":[]},{"id":"fb25b445.1f2768","type":"function","z":"c74669a0.6a34f8","name":"","func":"msg.payload = encodeURIComponent(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":370,"y":900,"wires":[[]]}]

Hi, i did try out the code and attached the debug output. I didn't receive any WhatsApp messages.

status code is 200 so the server received the request and responded 200. So you should of received the message.
P.s. you have posted your phone number and key in that image, you may want to remove it.

[edit]
tried your info in the callmebot browser url page, this was the response

Message to: +6xxxxxx
Text to send: {"name":"pippo","surname":"topolino","street":"blab labla"}
Message queued. You will receive it in a few seconds.

Thank you for your feedback. I did drop an email to CallmeBot and did get the response yesterday.
It was "I didn't implement JSON input yet. Only GET method is supported for the moment."

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.