const instanceId = 123;
const apiToken = 'your-api-token';
const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: 'Bearer ' + apiToken
},
body: JSON.stringify({
chatId: '447495021190',
message: 'I really like WhatsApp Messaging API!'
})
};
fetch('http://api.apifactory.pro/send-message', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
$instanceId = 123;
$apiToken = 'your-api-token';
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "http://api.apifactory.pro/send-message",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chatId' => '447495021190',
'message' => 'I really like WhatsApp Messaging API!'
]),
CURLOPT_HTTPHEADER => [
"accept: application/json",
"authorization: Bearer " . $apiToken,
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
// python -m pip install requests
import requests
instanceId = 123
apiToken = "your-api-token"
url = "http://api.apifactory.pro/send-message"
payload = {
"chatId": "447495021190",
"message": "I really like WhatsApp Messaging API!"
}
headers = {
"accept": "application/json",
"content-type": "application/json",
"authorization": "Bearer " + apiToken
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
curl --request POST \
--url http://api.apifactory.pro/send-message \
--header 'accept: application/json' \
--header 'authorization: Bearer your-api-token' \
--header 'content-type: application/json' \
--data '
{
"chatId": "447495021190",
"message": "I really like WhatsApp Messaging API!"
}
'