Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!doctype html>
<html lang="en">
<head>
  <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
  <title>Zipwhip Message Send API Example</title>
</head>
<body>
  
<div class="p-3">
  <h2>Zipwhip Message/Send API</h2>
  <p><a href="https://developers.zipwhip.com" target="_blank">developers.zipwhip.com</a></p>
</div>

<!-- Form for capturing session, mobile number and message body params  -->
<form class="border p-4 bg-light" action="https://api.zipwhip.com/message/send" method="POST">
  <div class="form-group">
      <label for="session">Session:</label>
      <input type="text" class="form-control" id="session" value="">
  </div>
  <div class="form-group">
      <label for="contacts">Mobile Number:</label>
      <input type="text" class="form-control" id="contacts" placeholder="2065551234" value="">
  </div>
  <div class="form-group">
      <label for="body">Message Body:</label>
      <textarea class="form-control" style="height:90px;" id="body" placeholder="Enter message body here"></textarea>
  </div>
  <input type="submit" class="btn btn-primary" id="submit" value="Submit">
</form>

<!-- Display Success or Failer Message after Submit -->
<div id="success-alert" class="mt-3 alert alert-success alert-dismissible" style="display:none;">
    <button id="close-alert" type="button" class="close">&times;</button>
    <strong>Message Sent</strong>
</div>

<div id="failed-alert" class="mt-3 alert alert-danger alert-dismissible" style="display:none;">
    <button id="close-alert" type="button" class="close">&times;</button>
    <strong>Message failed to send</strong>
</div>

<!-- Display JSON response after Submit-->
<div id="json-response" class="d-none py-4 border-bottom">
  <h3>Response</h3>
  <pre>
    <code class="language-json" id="api-response">
    </code>
  </pre>
</div>

</body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                $(document).ready(function() {
    $("#submit").click(function(event) {
        event.preventDefault();
        let session = $("#session").val();
        let contacts = $("#contacts").val();
        let body = $("#body").val();
        messageSend(session, contacts, body);
    });
});

function messageSend(sessionKey, phoneNumber, messageBody) {
    if (!sessionKey) {
        alert('Missing session key. Please login first.');
        return;
    } else if (!phoneNumber) {
        alert("Please enter a phone number.");
        return;
    } else if (!messageBody) {
        alert("Please enter a message body.");
        return;
    }
    $.post("https://api.zipwhip.com/message/send", {
                session: sessionKey,
                contacts: phoneNumber,
                body: messageBody
            },
            function(response, status) {
                if (response.success == true) {
                    $('#success-alert').fadeIn("slow");
                } else {
                    alert(response.response);
                };
            })
        .fail(function(response) {
            $('#failed-alert').fadeIn("slow");
        })
        // Display json results on page
        .always(function(response) {
            displayJsonResponse(response);
        });
}

// Display syntax highlighted json results
function displayJsonResponse(response) {
    $("#api-response").ready(function() {
        if ($("#api-response").length) {
            $("#api-response").text(status + '\n' + JSON.stringify(response, undefined, 2));
            $("#json-response").hide();
            $("#json-response").removeClass("d-none");
            $("#json-response").fadeIn("slow");
            Prism.highlightElement($('#api-response')[0]);
        };
    });
}

              
            
!
999px

Console