sending sms from a mobile browser

寵の児 提交于 2019-12-25 09:13:12

问题


Is there any updates for sending sms from the browser(mobile)? I've seen similar posts on this topic from here and here (actually both share the same method of sending sms).

Anyway the method of the above links is able to CREATE a message but not send it like so:

<a href="sms:+123456789?body=TheMessage">SEND</a>

When a user is browsing with a mobile device and clicks on the link it creates a new message ready to send to mobile number +123456789 with a message TheMessage. So it still requires the user to press send.

I'm looking for a method where the user doesn't need to press send. Any ideas?


回答1:


so this works with phps mail function, sending sms to mobile. you have to know the carrier being used in order for this to work...essentially every phone number is also an email address within its carrier....so i use verizon (i know, they sux), when you text me 757-757-7575, its really sending an email to my phoneNumber@carrier (7577577575@vtext.com).

this is very basic, in working demo, i've even hardcoded my carrier and number as the input values, although that may not be ideal for you.

essentially here's the mail function:


  $message = wordwrap( $_REQUEST['smsMessage'], 70 );
  $to = $_REQUEST['phoneNumber'] . '@' . $_REQUEST['carrier'];
  $result = @mail( $to, '', $message );

and the form markup


<form action="" method="post">
  <ul>
    <li>
      <label for="phoneNumber">Phone Number</label>
      <input type="text" name="phoneNumber" id="phoneNumber" placeholder="7577597204" value="7577597204" /></li>
              <li>
      <label for="carrier">Carrier</label>
      <input type="text" name="carrier" id="carrier" placeholder="vtext.com" value="vtext.com" /></li>
              <li>
      <label for="smsMessage">Message</label>
      <textarea name="smsMessage" id="smsMessage" placeholder="Text Message Goes Here Yo!..."></textarea>
    </li>
    <li>
      <input type="submit" name="sendMessage" id="sendMessage" value="Send Message" /></li>
  </ul>
</form>

i think i've done quite a wretched job explaining this, so i'm sorry if there's any confusion. here's working demo: http://dev.bowdenweb.com//php/sms/working-sms-demo2.html and i also saved it as a text file so you can see the php
http://dev.bowdenweb.com//php/sms/working-sms-demo2.txt

sorry i don't have a repo on github for this yet...i should probably do that today.

edit: here's a mailto demo using my sms email...it goes through the user's email, which is actually quite awkward. not sure why i wanted to try it...but it was useful for me to see the pre-populated email being created before i send them out.

http://jsfiddle.net/jalbertbowdenii/7jFee/



来源:https://stackoverflow.com/questions/18234732/sending-sms-from-a-mobile-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!