skip to Main Content

I am using Twillio API, to send WhatsApp Messages.

But the Message template needs to be pre-approved in order to send a message.

But It always fails when there are multiple lines of the message.

The reason is they match the new line as n, as the template is registered with a Unix-style line feed in their system, but My template is sending rn encoding for the new line which is window based.

How can I change newline encoding from rn to n in my system?

Thanks in advance for any help.

2

Answers


  1. Chosen as BEST ANSWER

    Resolved this issue using the below code.

    $windows_encoded_data = urlencode($data);
    
    $unix_encoded = str_replace("%0D%0A","%0A",$windows_encoded_data);
    
    $final_data = urldecode($unix_encoded);
    

  2. $str = str_replace("rn","n", $windowStr);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search