Snippets

Team Zoom PHP - bulk send using xml and curl

Created by Terence Foxcroft last modified Curtis Sahd
<?php

// note: the PHP cURL library must be installed to send using this method

$credentials = "YOUR_EMAIL_ADDRESS:YOUR-API-TOKEN";

$url = "https://www.zoomconnect.com/app/api/rest/v1/sms/send-bulk.xml";

$xml = new SimpleXMLElement("<?xml version=\"1.0\" encoding=\"utf-8\" ?><sendSmsRequests></sendSmsRequests>");

$message1 = $xml->addChild("sendSmsRequest");
$message1->addChild('message', "Test message 1");
$message1->addChild('recipientNumber', "27821234567");

$message2 = $xml->addChild("sendSmsRequest");
$message2->addChild('message', "Test message 2");
$message2->addChild('recipientNumber', "27821234568");

$data_string = $xml->asXML();

print($data_string);
 
$ch = curl_init($url);                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'Content-Type: application/xml',     
    'Authorization: Basic ' . base64_encode($credentials),                                                                           
    'Content-Length: ' . strlen($data_string))                                                                       
);                                                                                                                   
 
$result = curl_exec($ch);
echo 'Reponse ' . $result;

?>

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.