Wallogit.com
2017 © Pedro Peláez
PHP lib for integrating Whatools into your app easily.
PHP lib for integrating Whatools into your app easily, (*1)
This lib works only with v3 API. Please make sure your Whatools line is configured to use such API version., (*2)
The only thing you need is including this library and then create an API object by passing your Whatools API key as a parameter to the class constructor., (*3)
include("whatools.inc.php");
$w = new Whatools("Put here your API key");
Remember that you can get the API key for your Whatools line by logging into Whatools and then going to Advanced settings > REST API., (*4)
Logging in and out is the analog process in v3 API to subscribing and unsubscribing in older API versions. Nevertheless, in v3, when you log out you are effectively closing the connection between WhatsApp servers and your account, so you can be sure that you never miss a single message., (*5)
$w->login(); echo "Logged in as +", $w->whatsappInfo->cc, $w->whatsappInfo->pn, "\n"; $w->logout();
$w->nicknamePost("John Doe");
$nickname = $w->nicknameGet("John Doe");
$w->statusPost("To be, or not to be, that is the question.");
$status = $w->statusGet();
$w->avatarPost("Route for an image file");
$avatar = $w->avatarGet("Phone number in international format");
file_put_contents("avatar.jpg", $avatar);
$w->messagePost("Phone number in international format", "Body of the message");
$w->picturePost("Phone number in international format", "Route for an image file", "Optional caption");
$messages = $w->messageGet();
foreach ($messages as $message)
{
if ($msg->mine)
echo "> ", $msg->to;
else
echo "< ", $msg->from;
echo "\n\t\"", $msg->body, "\"";
echo "\n\t@", $msg->stamp;
echo "\n\tACK: ", $msg->ack, "\n";
}