Code samples

    EZAlert.me code samples

    First thing you should do (after subscribing to EZAlert.me) is to get your API key. Just go in your channel configuration page, click on "Show API keys" button and copy the key. API key is in the format YY-YYYYYYYYYYYY.
    Once you have your EZAlert.me channel API key, you are ready to send alerts.

    Here follow a few code samples for various languages.
    In each sample we used a dummy API key YY-YYYYYYYYYYYY and the same altert text "test alert".


    Unix/Windows command line - using curl (GET method)

    
    curl 'https://ezalert.me/v1/sendAlert?apikey=YY-YYYYYYYYYYYY&text=test+alert'
    

    Unix/Windows command line - using curl (POST method)

    
    curl -X POST 'https://ezalert.me/v1/sendAlert' --data-urlencode 'apikey=YY-YYYYYYYYYYYY' --data-urlencode 'text=test alert'
    

    Unix command line - using wget

    
    wget -qO - 'https://ezalert.me/v1/sendAlert?apikey=YY-YYYYYYYYYYYY&text=test+alert'
    

    Unix command line - using fetch (for BSD systems)

    
    fetch -o - 'https://ezalert.me/v1/sendAlert?apikey=YY-YYYYYYYYYYYY&text=test+alert'
    

    PHP - using file_get_contents()

    
    <?php
    $alert="test alert";
    $apikey='YY-YYYYYYYYYYYY';
    $rc=file_get_contents('https://ezalert.me/v1/sendAlert?apikey='.urlencode($apikey).'&text='.urlencode($alert));
    echo "API reply: $rc\n";
    ?>
    

    Javascript / NodeJS

    
    const https = require('https');
    https.get('https://ezalert.me/v1/sendAlert?apikey=YY-YYYYYYYYYYYY&text='+encodeURIComponent("Houston, we have a problem!"));
    

    C# Microsoft or Mono

    
    using System;
    using System.Net.Http;
    using System.Web;
    
    public class EzalertmeSample {
      private static HttpClient client = new HttpClient();
    
      public static void Main(string[] args)   {
           String apik="YY-YYYYYYYYYYYY"; // EZAlert.me channel API Key
          String text="This is my alert"; // Alert text content       String url="https://ezalert.me/v1/sendAlert?apikey=" + apik + "&text=" + HttpUtility.UrlEncode(text);        client.GetAsync(url);    // Send Alert (no answer expected)   } }

    Python - using requests module

    
    import requests
    params=(('apikey','YY-YYYYYYYYYYYY'), ('text','test alert'))
    rc=requests.get('https://ezalert.me/v1/sendAlert', params)
    print(rc.text)
    

    For more samples and details please checkout EZAlert.me repo on GitHub

    Copyright © 2023 EZAlert.me Powered by Codeguru