skip to Main Content

I want to send bulk sms using twillio notify in php having a custom text in place of the number (“From”) but dont seem to know how to go about it. Am using a messaging service. I would like to show the custom text instead of my sending number when the message is sent. Below is my code for sending the message

   <?php
require_once '/path/to/vendor/autoload.php';

use TwilioRestClient;

$accountSid = "your_account_sid";
$authToken = "your_auth_token";
$serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

$client = new Client($accountSid, $authToken);

$recipients = array($num1, $num2, ...); // Your array of phone numbers

$binding = array();
foreach ($recipients as $recipient) { 
    $binding[] = '{"binding_type":"sms", "address":"+1'.$recipient.'"}'; // +1 is used for US country code. You should use your own country code.
}

$notification = $client
->notify->services($service_sid)
->notifications->create([
    "toBinding" => $binding,
    "body" => $text
]);
?>

2

Answers


  1. You might be able to send them from Twilio verified phone numbers, but in-general that’s not good practice, as your “From” number will get flagged as spam by phone companies

    Further than that, you won’t be able to change the ‘From’ attribute, as Twilio doesn’t want you fraudulently impersonating other people’s phone numbers.

    If you can’t afford a short code, use a messaging service and buy a bunch of numbers to accommodate your volume.

    Login or Signup to reply.
  2. Twilio developer evangelist here.

    When you are using a messaging service, you can setup an alphanumeric sender ID as part of the copilot features for the service. Open up your messaging service settings and add an alphanumeric sender as shown in the screen shot below:

    The top copilot feature is Alpha Sender ID which you can enable with the check box.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search