Documentation

Home » Documentation » API » API WANotif

API WANotif

AdminWANotif
API
11 September 2020
Version 1.0

Make an HTTP request to access the whatsapp message service from WANOTIF.

CURL

curl --location --request POST 'https://send.wanotif.com/ssem_api/send_wa_api' 
--header 'Accept: application/json' 
--header 'Content-Type: application/json' 
--data-raw '{
    "api_key": "Your API KEY Wanotif",
    "reference_id": "Your application name",
    "phone":"6285xxxxxx",
    "message": "Your wonderful message to client"
}'

Javascript (Nodejs)

var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'https://send.wanotif.com',
  'path': '/ssem_api/send_wa_api',
  'headers': {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
    "api_key": "Your API KEY Wanotif",
    "reference_id": "Your application name",
    "phone":"6285xxxxxx",
    "message": "Your wonderful message to client"
});

req.write(postData);

req.end();

Python

import requests

url = "https://send.wanotif.com/ssem_api/send_wa_api"

payload = "{nt"api_key":"Your API KEY Wanotif",nt"reference_id":"Your application name",nt"phone":"6285xxxxxx",nt"message": "Your wonderful message to client"n}"
headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))

PHP

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://send.wanotif.com/ssem_api/send_wa_api",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{nt"api_key":"Your API KEY Wanotif",nt"reference_id":"Your application name",nt"phone":"6285xxxxxx",nt"message": "Your wonderful message to client"n}",
  CURLOPT_HTTPHEADER => array(
    "Accept: application/json",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Library Wanotif

Wanotif has provided PHP classes that support the following frameworks:

Codeigniter

  1. 1. Download lib_whatsapp.php via the following link https://gist.github.com/ifirmawan/fcb4028ef69edc234571e79e67fec166
  2. 2. Save lib_whatsapp.php in the application / libraries / directory
  3. 3. Create a controller for testing, for example Test_wanotif.php in the application / controllers / directory.
  4. 4. Follow the source code on the following Test_wanotif.php controller
  5. 5. Open a browser and point the url to {BASE_URL_APP}/index.php/test_wanotif/
class Test_wanotif extends CI_Controller {
    function index(){
        $whatsapp_api_key = 'YOUR API KEY WANOTIF';
        $phone = '6281xxxxxxxx';
        $message ='Your wonderful message to client';
        $this->load->library('lib_whatsapp');
        
        try{
            if($this->lib_whatsapp->send_whatsapp($whatsapp_api_key, $phone, $message)){
                echo "Success to send whatsapp message";
            }else{
                echo "failed to send whatsapp message";
            }
        } catch (Exception $e) {
            $error = $e->getMessage();
        }
    }
}

Laravel - COMING SOON

Tags