Snippets

Team Zoom PHP - send using json and file_get_contents

Created by Terence Foxcroft last modified Curtis Sahd
<?php

$credentials = "YOUR_EMAIL_ADDRESS:YOUR_API_TOKEN";

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

$data = new stdClass();
$data->message = 'Test message';
$data->recipientNumber = '+27821234567';

$data_string = json_encode($data);

$result = file_get_contents($url, null, stream_context_create(array(
    'http' => array(
        'method'           => 'POST',
        'header'           => "Content-type: application/json\r\n".
                              "Connection: close\r\n" .
                              "Content-length: " . strlen($data_string) . "\r\n" .
                              "Authorization: Basic " . base64_encode($credentials) . "\r\n",
        'content'          => $data_string,
    ),
)));

if ($result) {
    echo 'Response: ' . $result;
} else {
    echo "POST failed";
}

?>

Comments (0)

HTTPS SSH

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