-
Notifications
You must be signed in to change notification settings - Fork 80
Create break line in the message #16
Comments
plus one for this. It gives you then a little bit more freedom to "style" the message. |
Not working $_u.="Product Name:".$_productName."\n"; How to break line when i send message on whatsapp. i have try also %0A but not working. see hear http://stackoverflow.com/questions/27780542/whatsapp-create-break-line-in-the-message |
@rvpatel The code you posted seems to be PHP, not JavaScript. What exactly is not working? What are you trying to achieve? |
HTML: data-text="text I think that's what he wants to achieve. Definitely what i want to achieve. ..in PHP data-text="text_\n_more text_\n_" |
WhatsApp uses HTML internally to display the messages. (Source: https://github.com/venomous0x/WhatsAPI/blob/7099c1af303abbf9c2ea07801ffa88657ecd4665/src/protocol.class.php#L100-L151) |
Any working demo?? |
Hi there! I just have a similar issue and found one solution that works for me. In javascript I have my message with line breaks and line feed like this:
Sending that to Whatsapp won't work, you have to encodeURI first, as if it was for a mailto:
Sending encoded message as parameter like Mailto reference (5. Encoding): http://www.ietf.org/rfc/rfc2368 Tested on Android 6.0.1, Whatsapp 2.17.107 Hope it helps |
@rafael-santos , your solution is working for me too. You solved a three year old problem! Tested on Whatsapp 2.17.213, Android 6.0 Miguel |
@srmaikol you can also use https://www.url-encode-decode.com/ for line break. |
@rafael-santos 's solution works great - thank you! Here I just wanted to point out to the devs (please someone say if there's a better place to send this) that if you send a message using api.whatsapp.com then the preview of the message which appears immediately DOESN'T show the new lines... but if you then click 'SEND' the composed message which appears in web.whatsapp.com DOES show them. Example which displays this behaviour: https://api.whatsapp.com/send?phone=447777333333&text=Message%0awith%0anewlines |
Hi guys, This is my first post in this type of community, sorry for anything about my English (fault of google translator). To this day I have only received from you, but I feel that I can help some of them really: I have the same problem with Selenium. If this is useful for you too, you can resolve this problem by using something like CTRL + C / CTRL + V Like this:
|
The code running on api.whatsapp.com needs a minor change as below. When you follow this link https://api.whatsapp.com/send?phone=447777333333&text=Message%0awith%0anewlines then the following HTML code is part of what is generated on the initial page that the user sees:
The message is in there and has the newlines in it, but they are not displaying because of their context within an HTML div. It would simply need any %0a ('\n') characters to be converted to
This works and looks fine, as you can easily check e.g. using Chrome developer tools. This change would match what is intended and what already correctly appears after the user clicks to move on to the actual https://web.whatsapp.com page by pressing the 'SEND' button. |
In a future release you could add the command to break a line in the message, in that way is possible to send a title leave one break line and then show the url.
Regards
The text was updated successfully, but these errors were encountered: