API WANotif
ePAYWA - API WANotif
PHP
Required variables
- client_id = Your Client ID
- mobile = WhatsApp Number
- text = Text To Send
- API KEYS = Your API Key
Sending Text Message
function sendMessage() {
$url = 'https://app.wanotif.top/api/user/v2/send_message_url';
$clientId = 'CLIENT_ID';
$mobile = '918888888888';
$text = 'Hello';
$token = 'YOUR_API_KEYS';
$queryParams = http_build_query([
'client_id' => $clientId,
'mobile' => $mobile,
'text' => $text,
'token' => $token
]);
$apiUrl = $url . '?' . $queryParams;
$response = file_get_contents($apiUrl);
$data = json_decode($response, true);
if ($data) {
echo 'Response: ';
print_r($data);
} else {
echo 'Error: Unable to retrieve data.';
}
}
sendMessage();
Sending text message
function sendTextMessage() {
$url = 'https://app.wanotif.top/api/user/v2/send_message';
$body = [
'client_id' => 'CLIENT_ID', // Client ID here
'mobile' => '919999999999',
'text' => 'Hello world',
];
$token = 'YOUR_API_KEYS'; // Your API keys here
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $token,
];
try {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body));
$response = curl_exec($curl);
if ($response === false) {
throw new Exception(curl_error($curl));
}
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($httpCode >= 400) {
throw new Exception('Request failed');
}
$data = json_decode($response, true);
print_r($data); // Handle the response data as per your requirements
} catch (Exception $error) {
echo $error->getMessage();
}
}
sendTextMessage();
Sending Template Message
Required variables
- client_id
- mobile
- templet_id
- API KEYS
function sendTextMessage() {
$url = 'https://app.wanotif.top/api/user/v2/send_templet'; // Replace with your domain endpoint
$body = [
'client_id' => 'CLIENT_ID', // Client ID here
'mobile' => '919999999999',
'templet_id' => 1, // Your templet ID
];
$token = 'YOUR_API_KEYS'; // Your API keys here
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $token,
];
try {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body));
$response = curl_exec($curl);
if ($response === false) {
throw new Exception(curl_error($curl));
}
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($httpCode >= 400) {
throw new Exception('Request failed');
}
$data = json_decode($response, true);
print_r($data); // Handle the response data as per your requirements
} catch (Exception $error) {
echo $error->getMessage();
}
}
sendTextMessage();
Successful Response
{
"success": true,
"message": "The message has been successfully sent.",
"data": {}
}
What's Your Reaction?