POST request content gets lost

Post your questions and help other users.

Moderator: Martin

Post Reply
DonJaiquito
Posts: 3
Joined: 09 Apr 2017 10:47

POST request content gets lost

Post by DonJaiquito » 30 Apr 2017 12:05

hi there,

I wanted to use Automagic to forward sms messages to email. I wrote a tiny php script that is opened by automagic via http post.

Code: Select all

if ($_POST['type'] == "text") {
        $subject = "SMS erhalten";
        $message = "Absendername: ".$_POST['name']."\nNummer: ".$_POST['number']."\nNachricht: ".$_POST['text'];

}
In Automagic I use the http request action, entered the URL, Method post and under "Formular Feldliste" I wrote: type=text,number={sms_sender},name={contact_name},text={sms_text}

In general this works, but when an sms contains a comma (,) I only get the string until the comma, the rest of the string in {sms_text} is deleted. I don't know why...can you help me?

Thank you!

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: POST request content gets lost

Post by Martin » 30 Apr 2017 19:22

Hi,

Automagic replaces the variables before the text is processed further so a text like hello,bye leads to something like this:
type=text,number=1234567,name=The Name,text=hello,bye
so the word bye is not part of the text property anymore.

The form field list uses the CSV escaping mechanism for the comma separated list of fields. You could enclose the relevant fields in double quotes:
type=text,number={sms_sender},name={contact_name},"text={sms_text}"

Alternatively you could also prepare the field list in a script and then fill in the list at once in the HTTP Request action.
In a script:

Code: Select all

form_fields = newList();
addElement(form_fields, "type=text");
...
addElement(form_fields, "text="+sms_text);
In the HTTP Request action:
{form_fields,listformat,comma}
This will ensure that all fields are properly escaped.

Not sure if this helps but you could directly send a mail using action Mail with Gmail/Mailen mit Google Mail.

Regards,
Martin

DonJaiquito
Posts: 3
Joined: 09 Apr 2017 10:47

Re: POST request content gets lost

Post by DonJaiquito » 01 May 2017 07:31

Thank you! Using double quotes seems to work fine.

I have got another question:
Is it possible to forward an incoming email via sms or whatsapp? I imagine something like I write a mail with a telephone number as the subject and my message as the mail body and want automagic to use that mailbody and send it via sms/whatsapp to the number specified in the subject field?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: POST request content gets lost

Post by Martin » 02 May 2017 14:24

Hi,

Unfortunately the mail clients usually don't provide a good way to access the body of the mail. You could try to detect the mail with trigger Notification on Statusbar Displayed and see if the variable notification_text_big contains the entire body. You could forward the body or part of the body by SMS but not Whatsapp since Whatsapp provides no official support for third party apps to send messages.
You probably have to use a script to find and extract the subject from notification_text_big.

Regards,
Martin

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Re: POST request content gets lost

Post by akhileshg1988 » 03 May 2017 10:03

DonJaiquito wrote:hi there,

I wanted to use Automagic to forward sms messages to email.
Try the attached flow.
Attachments
Forward SMS To Mail.xml
Just enter the sender and recipient mail ids along with the pasword.
(12.81 KiB) Downloaded 666 times

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Re: POST request content gets lost

Post by akhileshg1988 » 03 May 2017 13:47

Did you (or others who downloaded the attached flow) find the flow useful? Please do inform.

Akhilesh Chandra Gairola

akhileshg1988
Posts: 109
Joined: 16 Apr 2014 04:57

Re: POST request content gets lost

Post by akhileshg1988 » 21 May 2017 10:12

An even better implementation of the previously attached flow is here.
The following flow forwards all the received as well as sent SMSes to your email id.
For the SMSes received and sent while your mobile device is offline (i.e. when no data connection is available either through mobile data or through Wifi), this flow creates a list (global) and stores all those SMSes in this list. When data connection is available on your device, this flow forwards one by one (i.e. not the entire list at once but each msg contained in the list as individual msg) all the msgs stored in the list to your email id.
After all the msgs stored in the global list have been forwarded to your email, it empties the global list.
Attachments
Group Forward SMS To Mail (Individual Messages Forwarded From Offline List).xml
Just enter the sender and recipient mail ids along with the pasword.
(13.78 KiB) Downloaded 676 times

Post Reply