PHP code example of inisiatif / whatsapp-qontak-php
1. Go to this page and download the library: Download inisiatif/whatsapp-qontak-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
inisiatif / whatsapp-qontak-php example snippets
use Inisiatif\WhatsappQontakPhp\Client;
use Inisiatif\WhatsappQontakPhp\Credential;
use Inisiatif\WhatsappQontakPhp\Message\Body;
use Inisiatif\WhatsappQontakPhp\Message\Button;
use Inisiatif\WhatsappQontakPhp\Message\Header;
use Inisiatif\WhatsappQontakPhp\Message\Message;
use Inisiatif\WhatsappQontakPhp\Message\Receiver;
use Inisiatif\WhatsappQontakPhp\Message\Language;
$credentials = new Credential('username', 'password', 'clientId', 'clientSecret');
$client = new Client($credentials);
// Create message receiver
$receiver = new Receiver('+6281318788271', 'Nuradiyana');
// [Optional] Create language, supported 'en' and 'id', default is 'id'
$language = new Language('id');
// [Optional] Create params message body
$body = [
new Body('Nuradiyana'),
new Body('Gorengan'),
];
// [Optional] Create header message, support "DOCUMENT", "VIDEO", "IMAGE"
$header = new Header(
Header::TYPE_DOCUMENT, 'https://example.com/link-to-file-url.pdf', 'file-name.pdf'
);
// [Optional] Create buttons
$buttons = [new Button('url', 'https://example.com')];
$message = new Message($receiver, $language, $body, $header, $buttons);
$response = $client->send('templateId', 'channelId', $message);
// Message Id and Receiver Name
echo $response->getMessageId();
echo $response->getName();
// All raw data
\var_dump($response->getData());
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Inisiatif\WhatsappQontakPhp\Message\Message;
use Inisiatif\WhatsappQontakPhp\Message\Receiver;
use Inisiatif\WhatsappQontakPhp\Illuminate\Envelope;
use Inisiatif\WhatsappQontakPhp\Illuminate\QontakChannel;
use Inisiatif\WhatsappQontakPhp\Illuminate\QontakNotification;
class InvoicePaid extends Notification implements QontakNotification
{
use Queueable;
public function via($notifiable): array
{
return [QontakChannel::class];
}
public function toQontak($notifiable): Envelope
{
// First create message object
$receiver = new Receiver('+6281318788271', 'Nuradiyana');
$message = new Message($receiver);
// Then create envelope object and return it
return new Envelope('templateId', 'channelId', $message);
}
}
bash
composer
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.