Snippets

Team Zoom PHP - send using json and file_get_contents

Updated by Curtis Sahd

File php-send-using-json-and-file-get-contents.php Modified

  • Ignore whitespace
  • Hide word diff
 
 $data = new stdClass();
 $data->message = 'Test message';
-$data->recipientNumber = '27821234567';
+$data->recipientNumber = '+27821234567';
 
 $data_string = json_encode($data);
 
Updated by Curtis Sahd

File php-send-using-json-and-file-get-contents.php Modified

  • Ignore whitespace
  • Hide word diff
 
 $credentials = "YOUR_EMAIL_ADDRESS:YOUR_API_TOKEN";
 
-$url = "https://www.zoomconnect.com/zoom/api/rest/v1/sms/send.json";
+$url = "https://www.zoomconnect.com/app/api/rest/v1/sms/send.json";
 
 $data = new stdClass();
 $data->message = 'Test message';
Updated by Terence Foxcroft

File php-send-using-json-and-file-get-contents.php Modified

  • Ignore whitespace
  • Hide word diff
 $data = new stdClass();
 $data->message = 'Test message';
 $data->recipientNumber = '27821234567';
-$data->dataField = 'testDataField';
 
 $data_string = json_encode($data);
 
Updated by Terence Foxcroft

File php-send-using-json-and-file-get-contents.php Modified

  • Ignore whitespace
  • Hide word diff
 
 $data_string = json_encode($data);
 
-$result = file_get_contents($url,null,stream_context_create(array(
+$result = file_get_contents($url, null, stream_context_create(array(
     'http' => array(
         'method'           => 'POST',
         'header'           => "Content-type: application/json\r\n".
 )));
 
 if ($result) {
-    echo $result;
+    echo 'Response: ' . $result;
 } else {
     echo "POST failed";
 }
Updated by Terence Foxcroft

File php-send-using-file-get-contents.php Deleted

  • Ignore whitespace
  • Hide word diff
-<?php
-
-$credentials = "YOUR_EMAIL_ADDRESS:YOUR_API_TOKEN";
-
-$url = "https://www.zoomconnect.com/zoom/api/rest/v1/sms/send.json";
-
-$data = new stdClass();
-$data->message = 'Test message';
-$data->recipientNumber = '27821234567';
-$data->dataField = 'testDataField';
-
-$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 $result;
-} else {
-    echo "POST failed";
-}
-
-?>

File php-send-using-json-and-file-get-contents.php Added

  • Ignore whitespace
  • Hide word diff
+<?php
+
+$credentials = "YOUR_EMAIL_ADDRESS:YOUR_API_TOKEN";
+
+$url = "https://www.zoomconnect.com/zoom/api/rest/v1/sms/send.json";
+
+$data = new stdClass();
+$data->message = 'Test message';
+$data->recipientNumber = '27821234567';
+$data->dataField = 'testDataField';
+
+$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 $result;
+} else {
+    echo "POST failed";
+}
+
+?>
  1. 1
  2. 2
HTTPS SSH

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