A simple PHP SDK for apiwha.com WhatsApp API
composer require rodrigowba/apiwha-php-sdk
use APIWHA\SDK\Factory;
$apiKey = 'API_KEY';
$client = (new Factory)->create($apiKey);
or
use APIWHA\SDK\Client;
$apiKey = 'API_KEY';
$client = new Client($apiKey, new GuzzleHttp\Client);
use APIWHA\SDK\Message\Message;
use APIWHA\SDK\Message\Image;
use APIWHA\SDK\Message\Audio;
use APIWHA\SDK\Message\PDF;
$number = '555555555555';
$message = new Message($number, 'Text message');
$message = new Message($number, 'Text message', 'custom_data');
$response = $client->send($message);
// Image Url must start with http and end with .jpg or .png
$url = 'http://addrress/image.jpg';
$message = new Image($number, $url);
$response = $client->send($message);
// Audio Url must start with http and end .ogg
// Only OGG audio supported
$url = 'http://addrress/audio.ogg';
$message = new Audio($number, $url);
$response = $client->send($message);
// PDF Url must start with http and end with .pdf
$url = 'http://addrress/document.pdf';
$message = new PDF($number, $url);
$response = $client->send($message);
$client->getMessages();
$client->getInboundMessages();
$client->getOutboundMessages();
$client->getNumberMessages($number);
$client->getCustomDataMessages($customData);
$response = $client->getCredit();
Methods | Return Type |
---|---|
create(string $apiKey) | APIWHA\SDK\Client |
Methods | Return Type |
---|---|
__construct(string $apiKey, \GuzzleHttp\Client $guzzle) | |
send(MessageInterface $message) | array |
getCredit() | array |
getMessages( string $type = null, string $number = null, string $customData = null, bool $markaspulled = false, bool $getnotpulledonly = false ) |
array |
getInboundMessages( string $customData = null, bool $markaspulled = false, bool $getnotpulledonly = false ) |
array |
getOutboundMessages( string $customData = null, bool $markaspulled = false, bool $getnotpulledonly = false ) |
array |
getNumberMessages( string $number, string $type = null, string $customData = null, bool $markaspulled = false, bool $getnotpulledonly = false ) |
array |
getCustomDataMessages( string $customData, string $type = null, bool $markaspulled = false, bool $getnotpulledonly = false ) |
array |
Constants | Value |
---|---|
TYPE_IN |
IN |
TYPE_OUT |
OUT |
Methods | Return Type |
---|---|
getNumber() | string |
getText() | string |
getCustomData() | string |
hasCustomData() | bool |
- APIWHA\SDK\Message\Message
- APIWHA\SDK\Message\Image
- APIWHA\SDK\Message\Audio
- APIWHA\SDK\Message\PDF