1. Go to this page and download the library: Download agielks/yii2-wablas 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/ */
agielks / yii2-wablas example snippets
'components' => [
'wablas' => [
'class' => \agielks\yii2\wablas\Wablas::class,
'endpoint' => 'my-wablas.com/api', // Change with your wablas API endpoint
'token' => 'my-token', // Change with your wablas API token
],
],
$data = [
[
'phone' => '6281218xxxxxx',
'message' => 'hello there',
]
];
/* @var $wablas \agielks\yii2\wablas\versions\V2 */
$wablas = $this->wablas->build('v2');
$response = $wablas
->sendMessage($data)
->send()
->response;
// Print whether response is OK
print_r($response->isOk);
// Print status code
print_r($response->statusCode);
// Print response data
print_r($response->data);
// Short command
$response = $this->wablas->build('v2')->sendMessage($data)->send()->response;
class CustomVersion extends BaseObject
{
public $wablas;
public function sendMessage(array $data): Wablas
{
$this->wablas->setRequest($this->wablas->client->post(['custom/send-message'])->setData($data));
return $this->wablas;
}
}
'components' => [
'wablas' => [
'class' => \agielks\yii2\wablas\Wablas::class,
'endpoint' => 'my-wablas.com', // Change with your endpoint
'token' => 'my-token', // Change with your wablas token,
'versions' => [
'custom' => CustomVersion::class,
]
],
],