aldok10/whatsappclientapi

Client API For Whatsapp Gateway Node.Js With JWT

v1.0.0 2021-04-07 15:26 UTC

This package is auto-updated.

Last update: 2024-10-22 19:23:53 UTC


README

PHP package to

Source API Server Whatsapp Gateway With Node.js : https://gitlab.com/aldo_k/whatsapp-node-api-with-jwt

Created because i don't really wanna get my hands dirty coz of using the old php-curl :shit: example.

Installation 🔥

composer require aldok10/whatsappclientapi

Example Usage 🎊

require_once __DIR__.'/../vendor/autoload.php';

use AldoKarendra\WhatsappClient\Send\Chat;
use AldoKarendra\WhatsappClient\Auth\Qr;

//use your own config
$config = [
	'base_url' => 'http://127.0.0.1:3002/api/v1/whatsapp',
	'public_key' => 'aldo_k',
	'secret_key' => 'mysecretpassword',
	// 'enable_error' => true,
	'enable_error' => false,
];

// use Qr service
$qr = new Qr($config);

// get barcode if not scan barcode whatsapp
$response = $qr->getQr('html');

if ($response === '{"msg":"Sudah Login"}') {
	
	// use chat service
	$chat = new Chat($config);

	// Send Msg
	$response = $chat->text('6281234567890','Send Msg!');
	echo "<pre style='background:#fafafa;'>";
	var_dump($response);
	echo "</pre>";
} else {
	// echo $response;
	if ($response=='{"status":false,"message":"Akses Terlarang!","data":null}'){
		echo "invalid access public_key / secret_key!";
	} else {
		echo "Get Access. <br>";
		echo $response;
	}
}

Make Sure Node Api Is Already Run With node api.js https://gitlab.com/aldo_k/whatsapp-node-api-with-jwt

Contributions 👌

Your contribution is always welcome!