To a WhatsApp phone number or group chat.
import requests
url = "https://app.api-messenger.com/sendMessage"
querystring = {"token":"YOUR_TOKEN"}
payload = [
{
"chatId": "79999999999@c.us",
"message": "Hello!"
}
]
headers = {"Content-Type": "application/json; charset=utf-8"}
response = requests.request("POST", url, json=payload, headers=headers, params=querystring)
print(response.text)
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.api-messenger.com/sendMessage?token=YOUR_TOKEN",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "[{\"chatId\":\"79999999999@c.us\",\"message\":\"Hello!\"}]",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json; charset=utf-8"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request POST \
--url 'https://app.api-messenger.com/sendMessage?token=YOUR_TOKEN' \
--header 'Content-Type: application/json; charset=utf-8' \
--data '[{"chatId":"79999999999@c.us","message":"Hello!"}]'
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://app.api-messenger.com/sendMessage?token=YOUR_TOKEN")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json; charset=utf-8'
request.body = "[{\"chatId\":\"79999999999@c.us\",\"message\":\"Hello!\"}]"
response = http.request(request)
puts response.read_body
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://app.api-messenger.com/sendMessage?token=YOUR_TOKEN"
payload := strings.NewReader("[{\"chatId\":\"79999999999@c.us\",\"message\":\"Hello!\"}]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json; charset=utf-8")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://app.api-messenger.com/sendMessage?token=YOUR_TOKEN")
.header("Content-Type", "application/json; charset=utf-8")
.body("[{\"chatId\":\"79999999999@c.us\",\"message\":\"Hello!\"}]")
.asString();
var axios = require("axios").default;
var options = {
method: 'POST',
url: 'https://app.api-messenger.com/sendMessage',
params: {token: 'YOUR_TOKEN'},
headers: {'Content-Type': 'application/json; charset=utf-8'},
data: [{chatId: '79999999999@c.us', message: 'Hello!'}]
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
You can flexibly filter the list of incoming and outgoing messages: select only those sent via the API, limit the selection by time range (by timestamp), and also view the results paginated using the page parameter.
import requests
url = "https://app.api-messenger.com/messages"
querystring = {"token":"YOUR_TOKEN"}
headers = {"Content-Type": "application/json; charset=utf-8"}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.api-messenger.com/messages?token=YOUR_TOKEN",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json; charset=utf-8"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request GET \
--url 'https://app.api-messenger.com/messages?token=YOUR_TOKEN' \
--header 'Content-Type: application/json; charset=utf-8'
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://app.api-messenger.com/messages?token=YOUR_TOKEN")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json; charset=utf-8'
response = http.request(request)
puts response.read_body
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://app.api-messenger.com/messages?token=YOUR_TOKEN"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Content-Type", "application/json; charset=utf-8")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.get("https://app.api-messenger.com/messages?token=YOUR_TOKEN")
.header("Content-Type", "application/json; charset=utf-8")
.asString();
var axios = require("axios").default;
var options = {
method: 'GET',
url: 'https://app.api-messenger.com/messages',
params: {token: 'YOUR_TOKEN'},
headers: {'Content-Type': 'application/json; charset=utf-8'}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
Receive notifications about private and group messages via incoming http requests to your server.
import requests
url = "https://app.api-messenger.com/setWebhook"
querystring = {"token":"YOUR_TOKEN"}
payload = {"webhook": "http://your.site/incoming_message.php"}
headers = {"Content-Type": "application/json; charset=utf-8"}
response = requests.request("POST", url, json=payload, headers=headers, params=querystring)
print(response.text)
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.api-messenger.com/setWebhook?token=YOUR_TOKEN",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"webhook\":\"http://your.site/incoming_message.php\"}",
CURLOPT_HTTPHEADER => [
"Content-Type: application/json; charset=utf-8"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
curl --request POST \
--url 'https://app.api-messenger.com/setWebhook?token=YOUR_TOKEN' \
--header 'Content-Type: application/json; charset=utf-8' \
--data '{"webhook":"http://your.site/incoming_message.php"}'
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://app.api-messenger.com/setWebhook?token=YOUR_TOKEN")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json; charset=utf-8'
request.body = "{\"webhook\":\"http://your.site/incoming_message.php\"}"
response = http.request(request)
puts response.read_body
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://app.api-messenger.com/setWebhook?token=YOUR_TOKEN"
payload := strings.NewReader("{\"webhook\":\"http://your.site/incoming_message.php\"}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json; charset=utf-8")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://app.api-messenger.com/setWebhook?token=YOUR_TOKEN")
.header("Content-Type", "application/json; charset=utf-8")
.body("{\"webhook\":\"http://your.site/incoming_message.php\"}")
.asString();
var axios = require("axios").default;
var options = {
method: 'POST',
url: 'https://app.api-messenger.com/setWebhook',
params: {token: 'YOUR_TOKEN'},
headers: {'Content-Type': 'application/json; charset=utf-8'},
data: {webhook: 'http://your.site/incoming_message.php'}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});