Page 1 of 1
POST request content gets lost
Posted: 30 Apr 2017 12:05
by DonJaiquito
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!
Re: POST request content gets lost
Posted: 30 Apr 2017 19:22
by Martin
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
Re: POST request content gets lost
Posted: 01 May 2017 07:31
by DonJaiquito
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?
Re: POST request content gets lost
Posted: 02 May 2017 14:24
by Martin
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
Re: POST request content gets lost
Posted: 03 May 2017 10:03
by akhileshg1988
DonJaiquito wrote:hi there,
I wanted to use Automagic to forward sms messages to email.
Try the attached flow.
Re: POST request content gets lost
Posted: 03 May 2017 13:47
by akhileshg1988
Did you (or others who downloaded the attached flow) find the flow useful? Please do inform.
Akhilesh Chandra Gairola
Re: POST request content gets lost
Posted: 21 May 2017 10:12
by akhileshg1988
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.