问题
I want the recipient of my SMS text message to see the name of my business, rather than the phone number. How is this possible? I am currently using Twilio, but I am open to suggestions involving other services.
回答1:
Twilio developer evangelist here.
I know this is a good few months since you asked this, but I wanted to update the possible answers for completeness. When you asked this in November 2014 it was not possible to send SMS messages from Twilio using an alphanumeric sender ID.
However, since May 2015 it has been possible to do so. All you need to do is replace the phone number as the From parameter of the API call to send a message with the text you want the sender ID to be. This currently works when sending SMS messages to 145 countries.
If I was doing this in Ruby, it would look like:
account_sid = YOUR_TWILIO_ACCOUNT_SID
auth_token = YOUR_TWILIO_AUTH_TOKEN
recipient_phone_number = RECIPIENT_PHONE_NUMBER
client = Twilio::REST::Client.new(account_sid, auth_token)
client.messages.create(
from: "ALPHANUMERICID",
to: recipient_phone_number,
body: "Hello World!"
)
Edit
Please note, that to use alphanumeric sender IDs on your Twilio account you need to have your account enabled. To do so, please contact twilio support with your account SID to request access.
回答2:
For those of you who have looked at @philnash s answer and still having problems, please read this. I'm using the twilio-ruby gem, and am in the UK.
I see a lot of places state that:
all you need to do is replace the
fromparameter.
This is not true!
Step 1
Contact Twilio and have them enabled it on your account.
Step 2
The second step is to make sure that to number you are using has the correct country code, 0779XXXXXXX and 779XXXXXXX are enough to send a text message when specifying a from number that has been previously purchased. The purchased number has a country of origin and therefore Twilio know to prefix it with the correct country code. However, an alphanumeric sender has no from number, and therefore no country of origin.
Using 0779XXXXXXX as the To param. Returns the error:
The 'To' number 0779XXXXXXX is not a valid phone number.
While technically correct, it isn't incorrect, it's just missing the country code.
Using 779XXXXXXX as the To param. Returns this error: The 'To' phone number: +1779XXXXXXX, is not currently reachable using the 'From' phone number: Foo via SMS. +1 is the USA phone prefix. The USA doesn't have an option to send as alphanumeric. This is how I stumbled onto the fix.
TLDR;
1. Contact Twilio to get them to enable it on your account
2. Make sure you prefix with the country code.
回答3:
I have found three services (not Twilio) that appear to address the question:
- Nexmo
- Plivo
- smsmessagesender
The above services support dynamic alphanumeric sender ID for outbound SMS, so you should be able to send a combination of 11 alpha-numeric characters as the sender ID of your message. Note the emphasis on outbound SMS. It appears that receiving incoming SMS on an alphanumeric sender ID is not possible.
If anyone has more experience with these services, please share.
Edit: Note that the availability of these services also depends on the laws of the jurisdiction where the services are to be used.
回答4:
As FullStack said, you can consider using another SMS API for this.
Nexmo, where I work, offers a high quality messaging service including the support of dynamic sender id. You can use any alphanumeric string to describe your application or brand where supported by carriers (where there are no restrictions on alphanumeric sender ids).
Some countries, such as the United States, don't allow alphanumeric sender ids. Other countries allow it, but have special restrictions that we take into account & work around to ensure maximum delivery.
You can find the full list of alpha-numeric sender ID compatible countries, along with carrier restrictions, here.
<?php
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query([
'api_key' => API_KEY,
'api_secret' => API_SECRET,
'to' => YOUR_NUMBER,
'from' => "AppName",
'text' => 'Hello'
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
来源:https://stackoverflow.com/questions/26856753/change-from-field-of-sms-text-message-for-recipient