Send bulk SMS campaigns with PHP and Routee
Send Bulk Messaging
Building consumer awareness and engagement is easy with bulk SMS API, which gives you the ability to deliver the same message to many recipients and design compelling marketing campaigns.
The Routee API will enable you to:
• Put your messaging load on Routee and stay focused on your application’s functionality.
• Customise your message by using Routee’s advanced Contacts API.
• Send your messages to multiple recipients.
• Personalise your message content using custom labels.
• Respect recipients’ privacy and legal restrictions per country, by using “Quite Hours” feature.
• Get insights on every message so to be sure that SMS were delivered on time.
• View reports, graphs and calculate the cost of your campaigns.
• Send large texts (more than 160 characters) written in any language
Let’s see how you can send a personalized message from your web application to all your customers.
First of all, you should import all your contacts into the Routee platform.
Note:
1. You can assign custom information to any contact and then use them as custom labels to the message bodies.
2. You can use as many custom labels as you wish.
3. Fallback values can be set for every custom label, in case the field is empty.
For instance, the following example states that custom label [firstName] will be replaced with [user] if a contact does not have the firstName label set.
A Contact’s default name value
“fallbackValues”: { “firstName”: “user” }
We assume that you have imported your contacts into Routee platform and grouped them under the name “users”.
Now, your application should make a Routee API call to: https://connect.routee.net/sms/campaign.
HTTP Request
Headers
Code:
You can check the default API calls’ values here.
In the following example we will schedule a Bulk SMS from “MindGames” application towards a contact list while getting campaign’s status updates in a predefined Callback URL.JSON
{ "campaignCallback":{ "strategy":"OnCompletion", "url":"https://www.exampleserver.com/mindgames/campaigns" }, "callback": { "strategy": "OnCompletion", "url": "https://www.exampleserver.com/message" }, "body":"Welcome to MindGames! Invite a friend and special gifts are waiting for you both. Learn more at https://my.link/url", "campaignName":"Welcoming", "to":[ "+30694xxxxxxxx", "+35594xxxxxxxx", "+44794xxxxxxxx", "+30694xxxxxxxx", "+22894xxxxxxxx", "+32294xxxxxxxx" ], "scheduledDate":"2017-08-20T09:00:01Z", "from":"MindGames" }The message is scheduled to be sent on August 20, 2017, at 09:00:01 UTC towards 6 recipients from 5 different countries.
Its body will look like:
Welcome to MindGames! Invite a friend and special gifts are waiting for you both. Learn more at https://my.link/url
For MindGames app, two callback URLs have been set, so to receive the status updates. The first will receive the final status of the campaign and the second, the final status for each recipient.
1st: https://www.exampleserver.com/mindgames/campaigns
2nd: https://www.yourserver.com/message
For Instance:
"https://connect.routee.net/sms/campaign", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{"campaignCallback":{"strategy":"OnCompletion","url":"https://www.exampleserver.com/mindgames/campaigns"}, "callback": {"strategy": "OnCompletion", "url": "https://www.exampleserver.com/message"}, "body":"Welcome to MindGames! Invite a friend and special gifts are waiting for you both. Learn more at https://my.link/url", "campaignName":"Welcoming", "to":["+30694xxxxxxxx", "+35594xxxxxxxx","+44794xxxxxxxx", "+30694xxxxxxxx","+22894xxxxxxxx", "+32294xxxxxxxx" ], "scheduledDate":"2017-08-20T09:00:01Z", "from":"MindGames"}", CURLOPT_HTTPHEADER => array( "authorization: Bearer 12dc9fe4-7df4-4786-8d7a-a46d307687f4", "content-type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }