im not sure but aapanel has a crontab, you can make it thouAny tips about crons? for campaigns?
You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.
Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"
im not sure but aapanel has a crontab, you can make it thouAny tips about crons? for campaigns?
yes, but what would the crontab code be like to be able to add it?im not sure but aapanel has a crontab, you can make it thou
I managed to decode it but I couldn't find the error;
<?php
namespace App\Services\Impl;
use App\Services\WhatsappService;
use Illuminate\Support\Facades\Http;
class WhatsappServiceImpl implements WhatsappService
{
private $url;
protected const ROUTE_SEND_TEXT = '/backend-send-text';
protected const ROUTE_SEND_MEDIA = '/backend-send-media';
protected const ROUTE_SEND_BUTTON = '/backend-send-button';
protected const ROUTE_SEND_TEMPLATE = '/backend-send-template';
protected const ROUTE_SEND_LIST = '/backend-send-list';
protected const ROUTE_SEND_POLL = '/backend-send-poll';
protected const ROUTE_LOGOUT_DEVICE = '/backend-logout-device';
protected const ROUTE_CHECK_NUMBER = '/backend-check-number';
protected const ROUTE_GET_GROUPS = '/backend-getgroups';
protected const ROUTE_START_BLAST = '/backend-blast';
public function __construct()
{
$this->url = env('WA_URL_SERVER');
}
private function sendRequest($route, $data): object
{
try {
$results = Http::withOptions(['verify' => false])->asForm()->post($this->url . $route, $data);
return json_decode($results->body());
} catch (\Throwable $th) {
throw $th;
}
}
public function fetchGroups($device): object
{
return $this->sendRequest(self::ROUTE_GET_GROUPS, ['token' => $device->body]);
}
public function startBlast($data): object
{
return $this->sendRequest(self::ROUTE_START_BLAST, [
'data' => json_encode($data),
'delay' => 1,
]);
}
public function sendText($request, $receiver): object | bool
{
return $this->sendRequest(self::ROUTE_SEND_TEXT, [
'token' => $request->sender,
'number' => $receiver,
'text' => $request->message,
]);
}
public function sendMedia($request, $receiver): object | bool
{
// GET FILE NAME from $request->url
$fileName = explode('/', $request->url);
$fileName = explode('.', end($fileName));
$fileName = $fileName[0];
$data = [
'token' => $request->sender,
'url' => $request->url,
'number' => $receiver,
'caption' => $request->caption ?? '',
'filename' => $fileName,
'type' => $request->media_type,
'ptt' => $request->ptt ? ($request->ptt == 'vn' ? true : false) : false,
];
return $this->sendRequest(self::ROUTE_SEND_MEDIA, $data);
}
public function sendButton($request, $receiver): object | bool
{
$buttons = [];
foreach ($request->button as $button) {
$buttons[] = ['displayText' => $button,];
}
// check url if exists,set to image if not exists cheeck thumbnail if exists set to image
$image = $request->url ? $request->url : ($request->image ? $request->image : '');
$data = [
'token' => $request->sender,
'number' => $receiver,
'button' => json_encode($buttons),
'message' => $request->message,
'footer' => $request->footer ?? '',
'image' => $image,
];;
return $this->sendRequest(self::ROUTE_SEND_BUTTON, $data);
}
public function sendTemplate($request, $receiver): object | bool
{
$templates = [];
$ii = 1;
foreach ($request->template as $template) {
$ii++;
$typedest = explode('|', $template)[0] == 'url' ? 'url' : (explode('|', $template)[0] == 'call' ? 'phoneNumber' : 'id');
$type = explode('|', $template)[0] == 'id' ? 'quickReplyButton' : explode('|', $template)[0] . 'Button';
$templates[] = [
'index' => $ii,
$type => [
'displayText' => explode('|', $template)[1],
$typedest => explode('|', $template)[2],
],
];
}
$image = $request->url ? $request->url : ($request->image ? $request->image : '');
$data = [
'token' => $request->sender,
'number' => $receiver,
'button' => json_encode($templates),
'text' => $request->message,
'footer' => $request->footer ?? '',
'image' => $image,
];
return $this->sendRequest(self::ROUTE_SEND_TEMPLATE, $data);
}
public function sendList($request, $receiver): Object | bool
{
$section['title'] = $request->title;
$i = 1;
foreach ($request->list as $menu) {
$i++;
$section['rows'][] = [
'title' => $menu,
'rowId' => 'id' . $i,
'description' => '',
];
}
$data = [
'token' => $request->sender,
'number' => $receiver,
'list' => json_encode($section),
'text' => $request->message,
'footer' => $request->footer ?? '',
'title' => $request->title,
'buttonText' => $request->buttontext,
];
return $this->sendRequest(self::ROUTE_SEND_LIST, $data);
}
public function sendPoll($request, $receiver): Object | bool
{
$optionss = [];
foreach ($request->option as $opt) {
$optionss[] = $opt;
}
$data = [
"token" => $request->sender,
"number" => $receiver,
"name" => $request->name,
"options" => json_encode($optionss),
"countable" => $request->countable === "1" ? true : false,
];
return $this->sendRequest(self::ROUTE_SEND_LIST, $data);
}
public function logoutDevice($device): object | bool
{
return $this->sendRequest(self::ROUTE_LOGOUT_DEVICE, ['token' => $device]);
}
public function checkNumber($device, $number): object | bool
{
return $this->sendRequest(self::ROUTE_CHECK_NUMBER, ['token' => $device, 'number' => $number]);
}
}
?>
Thx for decoding...I managed to decode it but I couldn't find the error;
PHP:<?php namespace App\Services\Impl; use App\Services\WhatsappService; use Illuminate\Support\Facades\Http; class WhatsappServiceImpl implements WhatsappService { private $url; protected const ROUTE_SEND_TEXT = '/backend-send-text'; protected const ROUTE_SEND_MEDIA = '/backend-send-media'; protected const ROUTE_SEND_BUTTON = '/backend-send-button'; protected const ROUTE_SEND_TEMPLATE = '/backend-send-template'; protected const ROUTE_SEND_LIST = '/backend-send-list'; protected const ROUTE_SEND_POLL = '/backend-send-poll'; protected const ROUTE_LOGOUT_DEVICE = '/backend-logout-device'; protected const ROUTE_CHECK_NUMBER = '/backend-check-number'; protected const ROUTE_GET_GROUPS = '/backend-getgroups'; protected const ROUTE_START_BLAST = '/backend-blast'; public function __construct() { $this->url = env('WA_URL_SERVER'); } private function sendRequest($route, $data): object { try { $results = Http::withOptions(['verify' => false])->asForm()->post($this->url . $route, $data); return json_decode($results->body()); } catch (\Throwable $th) { throw $th; } } public function fetchGroups($device): object { return $this->sendRequest(self::ROUTE_GET_GROUPS, ['token' => $device->body]); } public function startBlast($data): object { return $this->sendRequest(self::ROUTE_START_BLAST, [ 'data' => json_encode($data), 'delay' => 1, ]); } public function sendText($request, $receiver): object | bool { return $this->sendRequest(self::ROUTE_SEND_TEXT, [ 'token' => $request->sender, 'number' => $receiver, 'text' => $request->message, ]); } public function sendMedia($request, $receiver): object | bool { // GET FILE NAME from $request->url $fileName = explode('/', $request->url); $fileName = explode('.', end($fileName)); $fileName = $fileName[0]; $data = [ 'token' => $request->sender, 'url' => $request->url, 'number' => $receiver, 'caption' => $request->caption ?? '', 'filename' => $fileName, 'type' => $request->media_type, 'ptt' => $request->ptt ? ($request->ptt == 'vn' ? true : false) : false, ]; return $this->sendRequest(self::ROUTE_SEND_MEDIA, $data); } public function sendButton($request, $receiver): object | bool { $buttons = []; foreach ($request->button as $button) { $buttons[] = ['displayText' => $button,]; } // check url if exists,set to image if not exists cheeck thumbnail if exists set to image $image = $request->url ? $request->url : ($request->image ? $request->image : ''); $data = [ 'token' => $request->sender, 'number' => $receiver, 'button' => json_encode($buttons), 'message' => $request->message, 'footer' => $request->footer ?? '', 'image' => $image, ];; return $this->sendRequest(self::ROUTE_SEND_BUTTON, $data); } public function sendTemplate($request, $receiver): object | bool { $templates = []; $ii = 1; foreach ($request->template as $template) { $ii++; $typedest = explode('|', $template)[0] == 'url' ? 'url' : (explode('|', $template)[0] == 'call' ? 'phoneNumber' : 'id'); $type = explode('|', $template)[0] == 'id' ? 'quickReplyButton' : explode('|', $template)[0] . 'Button'; $templates[] = [ 'index' => $ii, $type => [ 'displayText' => explode('|', $template)[1], $typedest => explode('|', $template)[2], ], ]; } $image = $request->url ? $request->url : ($request->image ? $request->image : ''); $data = [ 'token' => $request->sender, 'number' => $receiver, 'button' => json_encode($templates), 'text' => $request->message, 'footer' => $request->footer ?? '', 'image' => $image, ]; return $this->sendRequest(self::ROUTE_SEND_TEMPLATE, $data); } public function sendList($request, $receiver): Object | bool { $section['title'] = $request->title; $i = 1; foreach ($request->list as $menu) { $i++; $section['rows'][] = [ 'title' => $menu, 'rowId' => 'id' . $i, 'description' => '', ]; } $data = [ 'token' => $request->sender, 'number' => $receiver, 'list' => json_encode($section), 'text' => $request->message, 'footer' => $request->footer ?? '', 'title' => $request->title, 'buttonText' => $request->buttontext, ]; return $this->sendRequest(self::ROUTE_SEND_LIST, $data); } public function sendPoll($request, $receiver): Object | bool { $optionss = []; foreach ($request->option as $opt) { $optionss[] = $opt; } $data = [ "token" => $request->sender, "number" => $receiver, "name" => $request->name, "options" => json_encode($optionss), "countable" => $request->countable === "1" ? true : false, ]; return $this->sendRequest(self::ROUTE_SEND_LIST, $data); } public function logoutDevice($device): object | bool { return $this->sendRequest(self::ROUTE_LOGOUT_DEVICE, ['token' => $device]); } public function checkNumber($device, $number): object | bool { return $this->sendRequest(self::ROUTE_CHECK_NUMBER, ['token' => $device, 'number' => $number]); } } ?>
i used this decrypted file, now the error isI managed to decode it but I couldn't find the error;
PHP:<?php namespace App\Services\Impl; use App\Services\WhatsappService; use Illuminate\Support\Facades\Http; class WhatsappServiceImpl implements WhatsappService { private $url; protected const ROUTE_SEND_TEXT = '/backend-send-text'; protected const ROUTE_SEND_MEDIA = '/backend-send-media'; protected const ROUTE_SEND_BUTTON = '/backend-send-button'; protected const ROUTE_SEND_TEMPLATE = '/backend-send-template'; protected const ROUTE_SEND_LIST = '/backend-send-list'; protected const ROUTE_SEND_POLL = '/backend-send-poll'; protected const ROUTE_LOGOUT_DEVICE = '/backend-logout-device'; protected const ROUTE_CHECK_NUMBER = '/backend-check-number'; protected const ROUTE_GET_GROUPS = '/backend-getgroups'; protected const ROUTE_START_BLAST = '/backend-blast'; public function __construct() { $this->url = env('WA_URL_SERVER'); } private function sendRequest($route, $data): object { try { $results = Http::withOptions(['verify' => false])->asForm()->post($this->url . $route, $data); return json_decode($results->body()); } catch (\Throwable $th) { throw $th; } } public function fetchGroups($device): object { return $this->sendRequest(self::ROUTE_GET_GROUPS, ['token' => $device->body]); } public function startBlast($data): object { return $this->sendRequest(self::ROUTE_START_BLAST, [ 'data' => json_encode($data), 'delay' => 1, ]); } public function sendText($request, $receiver): object | bool { return $this->sendRequest(self::ROUTE_SEND_TEXT, [ 'token' => $request->sender, 'number' => $receiver, 'text' => $request->message, ]); } public function sendMedia($request, $receiver): object | bool { // GET FILE NAME from $request->url $fileName = explode('/', $request->url); $fileName = explode('.', end($fileName)); $fileName = $fileName[0]; $data = [ 'token' => $request->sender, 'url' => $request->url, 'number' => $receiver, 'caption' => $request->caption ?? '', 'filename' => $fileName, 'type' => $request->media_type, 'ptt' => $request->ptt ? ($request->ptt == 'vn' ? true : false) : false, ]; return $this->sendRequest(self::ROUTE_SEND_MEDIA, $data); } public function sendButton($request, $receiver): object | bool { $buttons = []; foreach ($request->button as $button) { $buttons[] = ['displayText' => $button,]; } // check url if exists,set to image if not exists cheeck thumbnail if exists set to image $image = $request->url ? $request->url : ($request->image ? $request->image : ''); $data = [ 'token' => $request->sender, 'number' => $receiver, 'button' => json_encode($buttons), 'message' => $request->message, 'footer' => $request->footer ?? '', 'image' => $image, ];; return $this->sendRequest(self::ROUTE_SEND_BUTTON, $data); } public function sendTemplate($request, $receiver): object | bool { $templates = []; $ii = 1; foreach ($request->template as $template) { $ii++; $typedest = explode('|', $template)[0] == 'url' ? 'url' : (explode('|', $template)[0] == 'call' ? 'phoneNumber' : 'id'); $type = explode('|', $template)[0] == 'id' ? 'quickReplyButton' : explode('|', $template)[0] . 'Button'; $templates[] = [ 'index' => $ii, $type => [ 'displayText' => explode('|', $template)[1], $typedest => explode('|', $template)[2], ], ]; } $image = $request->url ? $request->url : ($request->image ? $request->image : ''); $data = [ 'token' => $request->sender, 'number' => $receiver, 'button' => json_encode($templates), 'text' => $request->message, 'footer' => $request->footer ?? '', 'image' => $image, ]; return $this->sendRequest(self::ROUTE_SEND_TEMPLATE, $data); } public function sendList($request, $receiver): Object | bool { $section['title'] = $request->title; $i = 1; foreach ($request->list as $menu) { $i++; $section['rows'][] = [ 'title' => $menu, 'rowId' => 'id' . $i, 'description' => '', ]; } $data = [ 'token' => $request->sender, 'number' => $receiver, 'list' => json_encode($section), 'text' => $request->message, 'footer' => $request->footer ?? '', 'title' => $request->title, 'buttonText' => $request->buttontext, ]; return $this->sendRequest(self::ROUTE_SEND_LIST, $data); } public function sendPoll($request, $receiver): Object | bool { $optionss = []; foreach ($request->option as $opt) { $optionss[] = $opt; } $data = [ "token" => $request->sender, "number" => $receiver, "name" => $request->name, "options" => json_encode($optionss), "countable" => $request->countable === "1" ? true : false, ]; return $this->sendRequest(self::ROUTE_SEND_LIST, $data); } public function logoutDevice($device): object | bool { return $this->sendRequest(self::ROUTE_LOGOUT_DEVICE, ['token' => $device]); } public function checkNumber($device, $number): object | bool { return $this->sendRequest(self::ROUTE_CHECK_NUMBER, ['token' => $device, 'number' => $number]); } } ?>
Awesome for your problem solving. Campaign sent but it has no delay even i set delay timer.To make it work you must edit file "custom-route.php" at "webhome/routes with:
PHP:<?php use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Artisan; Route::get('generate', function (){ return \Illuminate\Support\Facades\Artisan::call('storage:link'); })->name('generate'); Route::get('/schedule-run', function () { return Illuminate\Support\Facades\Artisan::call('schedule:run'); })->name('schedule-run'); Route::get('/clear-cache',function(){ dd('adsf'); return Artisan::call('optimize'); })->name("cache.clear"); ?>
----------------------
Now you can test: www.yourweb.com/schedule-run
For the cronjob i´m using this two every five minutes:
cd /YOURHOMEE/artisan schedule:run 1 >/dev/null 2>&1
curl "https://yourweb.com/schedule-run" >/dev/null 2>&1
On aaPanel it is working normally.ENV FILE:
APP_NAME=WAMD
APP_ENV=local
APP_KEY=base64xGRSZnMJVvMO7erMUXd683lMJwYFWpdxufKRbugeq8=
APP_DEBUG=true
APP_URL=https://api.wiidelivery.com.br
WA_URL_SERVER=https://api.wiidelivery.com.br
PORT_NODE=3100
APP_INSTALLED=true
LICENSE_KEY=16ed9971-0c47-5f69-45ea-a4ebc93e33
BUYER_EMAIL=[email protected]
TYPE_SERVER=hosting
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=wa_delivery
DB_USERNAME=wa_delivery
DB_PASSWORD=Ama6TWTSe56PzrZp
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
PORT = 3000
AUTH =mpedia-server-uUdkfgli783pkfnlaskogoighr
ORIGIN =http://localhost
WEBHOOK =
MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=465
MAIL_USERNAME=150c4cd5485345
MAIL_PASSWORD=f8e83444145085
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=[email protected]
MAIL_FROM_NAME="${APP_NAME}"
CONFIG:
install vps ubuntu 20.04, 4vcores 16gb ram, Aapanel
Instead of saying that aapanel is working normally!On aaPanel it is working normally.
Also note that this script has no errors and works as normal.
Why you guys facing issues?
Where did you host this script to run?
Could you tell us how the cron config was uploaded on your server, especially if it is not shared.Awesome for your problem solving. Campaign sent but it has no delay even i set delay timer.
So if i make campaign for 10 numbers, it will sent 10 numbers imediately without delay.
How to make delay timer works?
I use shared hosting bro.Could you tell us how the cron config was uploaded on your server, especially if it is not shared.
still not workingTo make it work you must edit file "custom-route.php" at "webhome/routes with:
PHP:<?php use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Artisan; Route::get('generate', function (){ return \Illuminate\Support\Facades\Artisan::call('storage:link'); })->name('generate'); Route::get('/schedule-run', function () { return Illuminate\Support\Facades\Artisan::call('schedule:run'); })->name('schedule-run'); Route::get('/clear-cache',function(){ dd('adsf'); return Artisan::call('optimize'); })->name("cache.clear"); ?>
----------------------
Now you can test: www.yourweb.com/schedule-run
For the cronjob i´m using this two every five minutes:
cd /YOURHOMEE/artisan schedule:run 1 >/dev/null 2>&1
curl "https://yourweb.com/schedule-run" >/dev/null 2>&1
Have you tried 2 device in one account mas bro?
We get it, advertisements are annoying!
However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.
If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.