2017 © Pedro Peláez
 

library whatools-php

PHP lib for integrating Whatools into your app easily.

image

waaltcom/whatools-php

PHP lib for integrating Whatools into your app easily.

  • Tuesday, September 22, 2015
  • by aesedepece
  • Repository
  • 4 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

whatools-php

PHP lib for integrating Whatools into your app easily, (*1)

Notice

This lib works only with v3 API. Please make sure your Whatools line is configured to use such API version., (*2)

API reference

Setting up

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

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();

Setting your nickname

$w->nicknamePost("John Doe");

Getting your nickname

$nickname = $w->nicknameGet("John Doe");

Setting your status message

$w->statusPost("To be, or not to be, that is the question.");

Getting your status message

$status = $w->statusGet();

Setting your avatar

$w->avatarPost("Route for an image file");

Getting and storing someone's avatar

$avatar = $w->avatarGet("Phone number in international format");
file_put_contents("avatar.jpg", $avatar);

Sending a message

$w->messagePost("Phone number in international format", "Body of the message");

Sending a picture

$w->picturePost("Phone number in international format", "Route for an image file", "Optional caption");

Retrieving and printing messages received and sent since last logout

$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";
}

The Versions

22/09 2015

dev-master

9999999-dev

PHP lib for integrating Whatools into your app easily.

  Sources   Download

The Requires

  • php >=5.3
  • ext-curl *
  • ext-gd *