I would like to add a "Text Me" form to my website that will allow users to type their Name, Phone Number, and a Message that i receive on my phone via SMS. I would prefer something easy and free, perhaps a code snippet. Does anybody have any suggestions for a "Text Me" form or a service that provides one?
A quick google-search reveals (at least for German) customers: lox24.eu - they have a VERY simple way for sending SMS:
https://www.lox24.eu/API/httpsms.php?konto=<yourId>&password=<yourPassword>&service=<yourTariff>&text=<SMSText>&from=<yourSender>&to=<receivingNumber>
All you have to do, would be creating a short text from the $_POST variables of your form and then do a HTTP-request (preferrably cURL) from within the PHP-page that receives the form-data.
You might try to google for "websms api" to find a SMS-gateway in your country that provides the services you need.
HTH
^KMP
I recommend If This Then That. You can hit a simple web backend, supplying a JSON payload, and IFTTT will then send an SMS to your cell with the payload text, or whatever text you want.
Maker channel: https://ifttt.com/maker
SMS channel: https://ifttt.com/sms
IFTTT will abstract away the specifics of how the text is sent (doesn't matter what carrier, what country, etc.) and it will (probably) break the text into properly sized chunks. If not, you might have to do that yourself, though - just use substr() to divide the text payload into chunks of 160 characters and hit the backend as many times as necessary for the message to be sent.
You can use raw cURL to hit the backend, but I find that Guzzle is a great PHP library for making web requests of any kind.
A lot of mobile carriers in the US (not sure about abroad) will have a text equivalent email. For example, AT&T will text you if you send an email to yourmobilenumber#txt.att.net. Its free.
Related
I'm a bit confused here and due to the keywords involved Google has not been much help. I want to send text messages from my website to users with cellphones via SMS. Sounds simple enough using things like 1234567890#carrier.com with php mail scripts right? Well one thing I've encountered before is that sometimes it sends an MMS(multimedia message) instead of a regular text message.
What I am trying to find out(using keywords in Google, send text message phone number php) is how to get a phone number for your website? I've seen sites that actually have a phone number linked to the site that you can receive messages from.
Example Facebook uses 32665 to send and receive messages on.
How do you accomplish this?
Is it any way possible using the 1234567890#carrier.com with php mail to strictly only send a text message and not multimedia?
Example php mail script using a phone number:
<?PHP
mail("5558349324#vtext.com", "", "Test SMS", "From: RRPowered <test#rrpowered.com>rn");
?>
Also thanks to any help ahead of time, because I am really really confused at this point.
UPDATE: I just tried using the regular PHP mail functions to a phone number and it appears to cut the messages off at around 140 characters(I believe that is standard message size).
UPDATE 2: Before anyone mentions API like Text Magic, I am aware of those things, BUT I am wanting to build my own code instead of integrating someone elses API(if possible).
I'm using Asterisk with chan_dongle (and Huawei UMTS stick) on Debian Wheezy. I can send and receive SMS successfully. The 7-bit de/encoding work is done by a simple PHP script.
My problem is, that I can't receive concatenated SMS. This is the Base64 text from two different messages:
Ym9LZWl1a1NfYUNnSU1PUVVXWXNxR21FXVtBYm9LZWl1a1NfYUNnSU1PUVVXWXNxR21FXVtBYm9LZWl1a1NfYUNnSU1PUVVXWXNxR21FXVtBYm9LZWl1a1NfYUNnSU1PUVVXWXNxR21FXVtBYm9LZWl1a1NfYUNnSU1PUVVXWXNxR21FXVtBYm9LZWl1a1NfYUNnSU1PUVVX
WHNxR21FXVtBYm9LZWl1a1NfYUNnSU1PUVVXWXNxR21FXVtBYm9LZWl1a1NfYUNnSU1PUVVXWXNxR21FXVtBYm9LZWl1a1NfYUNnSU1PUVVXWXNxR21FXVtBYm9LZWl1a1NfYUNnSU1PUVVXWXNxR21FXVs=
CENdV0tBTH1lQUhLU11LQShLU1ldQ1FbS0FCXUFIS2VBYENzZ0NNS0dDZUlbAldpU19dXUAIS1NdS0FgS2VneV1ZU0dRS0FgQ3NnQ01LR0NlSUEEX11rZ0EgEx1BUGpACislU0BYQ2tpS2l1QEBgcGBsQGxyaHJAaHJiYkBubGBkdkAmS2VTS11da1tbS2V1cmJiZmxsbmxo
XEAOfVlpU09BRFNnQWZiXGBwXGRgYmhcAA==
The first one is a simple repeating "qwertz..." dummy text, sent from my Android phone.
The second one is a (German) reply from a service provider with a coupon code.
The first one looks easy to decode. 7/8 bit magic and we're done.
But the second one is really strange. Any ideas how to decode it?
There is only way to deal with multipart SMS is working as PDU with it and concatenating in your application.
I'm using Sendgrid and their Parse API to send/receive email. The Parse API allows one's web app to receive email as a $_POST but the problem is that in the $_POST I want to be able to extract the message itself from its prior messages and meta data that get chained along.
To show you what I mean in the following picture, i'd just like to capture the text, "trying sending from 12373 to 12373 from GMAIL" and not all the junk below it. If that is not possible, does anyone have any suggestions on how to parse the email body ($_POST['text']) such that I can separate out the message itself?
The problem is see is that depending on the email client (gmail, outlook, etc.), It's not clear to me that the date information, in this case: "On Wed, Jan 23, 2013...", will allows follow the message itself. If all email client's put the date beneath the message, then it would seem I could design a fancy regex to look for a line break followed by a date or something. Thoughts?
You have a couple of options:
1) Insert a token that splits the emails
You could do something like --- reply above this line --- and then cut out everything below that token.
2) Use an email reply parsing library
There is a really good one done by github, but it's in ruby. There's a php port though that might be good for what you need:
Fully working code:
<?php
require_once 'application/third_party/EmailReplyParser-master/src/autoload.php';
$email = new \EmailReplyParser\Email();
$reply = $email->read($_POST['text']);
$message=$reply[0]->getContent();
$message=preg_replace('~On(.*?)wrote:(.*?)$~si', '', $message);
//Last line is needed for some email clients, e.g., some university e-mails: foo#bar.edu but not Gmail or Hotmail, to get rid of "On Jan 23...wrote:"
//This failure to remove "On Jan 23...wrote:" is a known issue and is documented in their README
?>
There's simply no guaranteed way to parse quoted message threads from an email message, so you won't find a regex or any other code that will work in all cases. There's no standard to define formatting of replies, and as you've already observed different mail clients use different conventions. Many, in fact, will allow the user to edit the quoted text. Also, users can paste in unrelated messages, with or without headers, resulting in a mix-and-match of formats.
If you can record and keep the history of all messages as they are sent and received, then you can (usually, but not always) use the In-Reply-To header (see RFC-5322) to locate the previous message by matching it's Message-ID header, and do a diff on the body and remove duplicate text runs. It's apparent that some email systems do this to improve their presentations, but I'm not aware of any available open source code.
// cut quoted text, https://regex101.com/r/xO8nI1/5
$message = preg_replace('/(On\s.*<\n){0,1}(.*\n(\n){0,1}((^>+\s?.*$)+\n?)+)/mi', '', $message);
How about replies in languages other than English? We came out with solution to add marker, but instead of translating it for every email (based on user's language) we put some invisible characters into it (zero width space U+200B , to be precise). Basing on "On..." regexp it's error prone, it can easily cut some email content.
i have studied and implemented Ray wenderlich's awesome tutorials on apns, and i am using this php script on server side
https://github.com/sebastianborggrewe/PHP-Apple-Push-Notification-Server
every thing is going well, but i just want to know that how can i send push notification in a language other than english, like arabic, urdu, hindi or french...???(i am sending notifications from php server using a web form) this is first part of question, the other part is that can i send a voice message with push notification, i know that there is a property for sound in apns but dont know its max. length (max length of push notification is 256 bytes). plz. guide me thanx and Regards Saad.
Sound support is limited to playing audio files of the app (you include PushSound.aiff in your app and send "PushSound.aiff" in your apns-message.. that's all you can do!)
For localization, you [need to include localized strings in your app and then include the String-Key(ID) in the push message.
You should read the guide apple provides for all questions regarding push notifications
To add localized strings, you can add a strings file (file->new, select iOS/Resource->Stringsfile; name it Localizable.strings). You can add format strings ("%# has sent you a new message") and supply the format string's arguments in the push notification (see guide).
Again there is a internationalization guide
i have an iphone 3g and can successfully send text messages using the PHP mail() function. My issue is that for each message i receive, the "telephone number" associated with the incoming text message changes each time. If possible, I would like to somehow make this number constant so that I can take advantage of iphone's ability to aggregate all text messages from the same telephone number -Otherwise my iphone would be cluttered with messages. Is there a way to do this?
an example of the numbers I receive would be 1(410) 000-001, 1(410) 000-002, 1(410) 000-003, etc... can i make this constant somehow?
$message = stripslashes("new user just joined!");
mail("8185551111#txt.att.net", "Subject", "$message");
please let me know! thanks...
This is likely more to do with ATT than your PHP code.
This is a limitation of the carrier's email-to-SMS gateway. There's no way to guarantee which number the message will come from.
SHAMELESS PROMO: You could use a service like Twilio (whom I work for) and get a phone number for $1/month which you would be able to always send from. There's a ton of PHP sample code to get you started. There are other SMS APIs out there as well so look around and find the one that you like best.