Snippets

Team Zoom PHP - 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.xml";

$xml = new SimpleXMLElement("<?xml version=\"1.0\" encoding=\"utf-8\" ?><sendSmsRequest></sendSmsRequest>");
$xml->addChild('message', "Test message");
$xml->addChild('recipientNumber', "+27821234567");
                                                              
$data_string = $xml->asXML();
 
$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.