0

I have a question about the Subscribe function in Twilio.

When a user let me have their number from a form on my website Twilio sends them a text/sms.

How can i make it so that Twilio sends several (4-5) messages with 1 day apart.

My guess is that we have to set some kind of loop that picks a new message and some sort of timer to send multiple txt/sms

Here is how the send array looks like in twiliosubscribe.php

$client->account->messages->create(array(
'To' => $_POST['phone'],
'From' => "+142xxxxx",
'Body' => "This is some message for " . $_POST['name'],
));
echo '<pre>';
//print_r($client);
echo '</pre>';
// Display a confirmation message on the screen
echo "Sent message to {$_POST['name']}";

Any ideas on how i can do this?

Thanx

Richard Stenstierna
  • 2,155
  • 3
  • 16
  • 16

1 Answers1

0

Twilio Evangelist here.

You can easily write some code that uses Twilio to achieve what you're after.

You'll need some sort of background process that can do this. So you will need to store the users details (phone number, the message you want to send) in a database or other persisted store. Then you need a PHP process or Cron job that can send the message for you. A little light Googling reveals some more instructions:

Then, inside the script that is run by one of these methods, you need to load the users data from your persisted store/database, work out what message you are due to send them, and use the Twilio REST API to send the message.

Hope this helps.

Community
  • 1
  • 1
xmjw
  • 3,154
  • 21
  • 29