Whatsapp API 換行


只要建立一個 Whatsapp api 的連接, 按下連結後便可以發送 Whatsapp 短信, 例如:

https://api.whatsapp.com/send?phone=PHONENO&text=testing

按下以上連結, 便會出現 Whatsapp API 的視窗, 如果用安裝有 Whatsapp 的手機打開, 便會自動開啟 Whatsapp, 對方的電話是 PHONENO, 短信內容是 testing.

但如果要把一段較長的短信以換行的方式分開, 我試過用 \n, \r, \r\n 等都不成功, 找了一下資料, 要用 %0a 字串, 例如:

https://api.whatsapp.com/send?phone=PHONENO&text=testing1%0atesting2%0atesting3

以上連結便會出現:

testing1
testing2
testing3

Leave a Reply