开发者

Sending hidden fields via POST in iPhone in-app email

开发者 https://www.devze.com 2022-12-25 19:48 出处:网络
I\'m letting my App\'s user send email from within the app to share some content on myserver.To do so I need to include a button with two bits of data and I want to use POST to keep it somewhat hidden

I'm letting my App's user send email from within the app to share some content on myserver. To do so I need to include a button with two bits of data and I want to use POST to keep it somewhat hidden. I've decided to add an html form using POST and two hidden fields in the email rather, like so:

NSString *buttonCode = [NSString stringWithFormat:@"<form method='post' action='http://www.example.com/iphone/nifty.php'>
 <input type='hidden' name='dataOne' value='%@'>
 <input type='hidden' name='dataTwo' value='%@'>
 <input type='submit'value='Submit'></form>",dataOne, dataTwo];
NSString *emailBody = [NSString stringWithFormat:
        @"<b>%@ - %@</b>\n\n<HR WIDTH=200 SIZE=2 COLOR=#755f0f ALIGN=CENTER>\n Here is a email:<br><br>%@", 
         dateString, 
         timeString,
         buttonCode];
[picker setMessageBody:emailBody isHTML:YES];

I've confirmed by looking at the raw source of the email that the form is constructed correctly and I've copied and pasted it into a web page and it works.

So here is the problem. When I click on the button in the received email (using apple's mail client) the dataOne and dataTwo variables don't get pas开发者_如何学运维sed to my server.

Is there a better way to do this or is the issue with my mail client?

====== update ==========

I think this may be related to the line the iPhone adds to the email:

--Apple-Mail-1--23863057 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

When I add enctype="text/html" to the form in the test html on the server as mentioned above the variables are not received.

Is there a way to alter this from the iPhone and send it another way?


The enctype just tells the mail client that the email contains HTML, the problem is that your mail client is dropping the fields.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号