Documentation ezWapi

Last updated: January 18th, 2019

RESTfull API

GET http://localhost:8080

Send Message Text


<?php
$curl = curl_init();

$data = [
	'act' => 'send_message',
	'phone' => '081XXXXXXX',
	'caption' => base64_encode('test pesan from ezwapi.com'),
	'type' => 'text',
	'to' => '081XXXXXXX',
];

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, "http://localhost:8080?".http_build_query($data));
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

print_r($result);

?>
                                        
Request parameters:
act Required send_message
type Required text
phone Required Whatsapp numbers that will send messages. You can use the country code prefix or not. Example: 081223xxxx
to Required Whatsapp numbers that will receive messages. You can use the country code prefix or not. Example: 081223xxxx
caption Required Text message to be sent. Format: UTF-8 or UTF-16 string. for single newline (\n), double newline (\n2)
GET http://localhost:8080

Send Message File


<?php
$curl = curl_init();

$data = [
	'act' => 'send_message',
    'phone' => '081XXXXXXX',
    'caption' => base64_encode('test pesan from ezwapi.com'),
	'url' => base64_encode('http://example.com/test.jpg'),
    'type' => 'file',
    'to' => '081XXXXXXX',
];

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, "http://localhost:8080?".http_build_query($data));
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

print_r($result);

?>
                                        
Request parameters:
act Required send_message
type Required file
phone Required Whatsapp numbers that will send messages. You can use the country code prefix or not. Example: 081223xxxx
to Required Whatsapp numbers that will receive messages. You can use the country code prefix or not. Example: 081223xxxx
caption Required Base64 encode Text message to be sent. Format: UTF-8 or UTF-16 string. for single newline (\n), double newline (\n2)
url Required Base64 encode url file (jpg, png, txt, pdf, doc, docx, xls, csv, xml, zip, mp3, mp4)
Output API
Output parameters:
code 200 Send Message success
code 300 Send Message Error / phone account whatsapp not ready
code 404 Param not found / error request
GET http://localhost:8080

Filter Number


<?php
$curl = curl_init();

$data = [
	'act' => 'filter_number',
    'phone' => '081XXXXXXX',
    'target' => '081XXXXXXX',
];

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, "http://localhost:8080?".http_build_query($data));
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

print_r($result);

?>
                                        
Request parameters:
act Required filter_number
phone Required Whatsapp numbers that will send messages. You can use the country code prefix or not. Example: 081223xxxx
target Required Whatsapp numbers that will receive messages. You can use the country code prefix or not. Example: 081223xxxx
Output API
Output parameters:
code 200 Phone valid
code 300 phone not valid
code 404 Param not found / error request
Webhook

Code webhook


<?php
header('Content-Type: application/json');
if(isset($_POST['data'])){
	$data = json_decode($_POST['data'],true);
	$result['from'] = $data['sender']['id'];
	$result['name'] = $data['sender']['name'];
	$result['to'] = $data['to'];
	$result['message'] = $data['body'];
	print_r(json_encode($result));
}
die();

                                        
Output Webhook:

{"from":"[email protected]","name":"ezWapi","to":"[email protected]","message":"Test message"}