fanzly / whatsapp
Professional PHP & Laravel package for Fanzly.net WhatsApp Messaging, Campaigns, and OTP Verification API with a bilingual single-page UI and registration shortcodes.
Requires
- php: ^8.2
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^10.5|^11.0
Suggests
- illuminate/support: Required for Laravel integration (^10.0|^11.0|^12.0)
Provides
None
Conflicts
None
Replaces
None
README
A professional, fully translated (Arabic RTL / English LTR) PHP 8.2+ and Laravel 10/11/12 package for integrating Fanzly.net WhatsApp Messaging, Broadcast Campaigns, and OTP Verification APIs — complete with a tabbed Single-Page Control UI designed for both developers and non-technical subscribers, plus Registration Shortcodes.
Key Features
- Account-Owned WhatsApp Sending (
customonly): All WhatsApp messages and campaigns are sent exclusively from the account owner's connected WhatsApp number on Fanzly.net (never via shared system numbers). - Framework-Agnostic Core + Laravel Integration: Works standalone in any Pure PHP 8.2+ project or via Laravel Auto-Discovery.
- Automatic Settings Redirect Route: Installing the package immediately registers
/fanzlyand redirects/fanzly-settings(and/fanzly/settings) directly to the package control center. - Tabbed, User-Friendly UI (
/fanzly):- Bilingual switcher (العربية / English) with automatic RTL/LTR and Light/Dark themes
- Overview & Connection tab: verify platform connection & confirm your connected WhatsApp number is active
- Options & Shortcodes tab: configure OTP & campaign options and enable OTP checkboxes for Registration / Login / Reset to reveal copyable shortcodes (
[fanzly_register_otp],[fanzly_login_otp],[fanzly_reset_otp]) with a live preview - Send & Verify OTP tab: send OTP codes, check delivery status, and verify codes with human-readable status cards
- Direct WhatsApp tab: message any number with quick templates
- WhatsApp Campaigns tab: launch personalized bulk campaigns (
{name},{phone}), import CSV/TXT files, optional queue dispatch, and campaign history - Activity Logs tab: clean, translated operation history
Installation (Laravel)
composer require fanzly/whatsapp php artisan fanzly:install --migrate
Add your Fanzly API token to .env:
FANZLY_BASE_URL=https://fanzly.net FANZLY_API_TOKEN=your_api_token_here
Automatic Routes & Authentication Protection
Once installed, the control center routes are protected by ['web', 'auth'] middleware by default so unauthenticated visitors cannot access your settings or API token:
- Control Center & Settings UI:
/fanzly(route('fanzly.dashboard')) - Settings Redirect Route:
/fanzly-settings(route('fanzly.settings.redirect')) → redirects to/fanzly - Settings Alias Route:
/fanzly/settings(route('fanzly.settings.alias')) → redirects to/fanzly - Public Shortcode Widget Endpoints:
/fanzly/widget/send-otpand/fanzly/widget/verify-otp(throttled viathrottle:10,1and only active when enabled in settings)
You can customize the dashboard middleware (for example, restricting to admins/roles) in .env or config/fanzly.php:
FANZLY_ROUTE_MIDDLEWARE=web,auth
Pure PHP Usage
<?php require 'vendor/autoload.php'; use Fanzly\WhatsApp\Client\FanzlyClient; $fanzly = new FanzlyClient('YOUR_API_TOKEN'); // 1. Check platform connectivity & token $connection = $fanzly->verifyConnection(); // 2. Check active custom WhatsApp sender using a test phone number $whatsappCheck = $fanzly->verifyWhatsAppNumber('+201000000000'); // 3. Send & verify OTP $otp = $fanzly->sendOtp('+201000000000', length: 6, numeric: true); $verification = $fanzly->verifyOtp('+201000000000', '123456'); // 4. Send a direct WhatsApp message (always sent via your connected number) $message = $fanzly->sendWhatsApp('+201000000000', 'Hello from Fanzly!'); // 5. Launch a personalized WhatsApp campaign $campaign = $fanzly->sendCampaign( recipients: [ ['phone' => '+201000000001', 'name' => 'John Doe'], ['phone' => '+201000000002', 'name' => 'Jane Doe'], ], messageTemplate: 'Hello {name}, welcome to our service!', delayMs: 350 );
Laravel Usage & Registration Shortcode
Facade API
use Fanzly\WhatsApp\Laravel\Facades\Fanzly; Fanzly::verifyConnection(); Fanzly::verifyWhatsAppNumber('+201000000000'); Fanzly::sendOtp('+201000000000'); Fanzly::verifyOtp('+201000000000', '123456'); Fanzly::sendWhatsApp('+201000000000', 'Welcome!'); Fanzly::launchCampaign('Promo', ['+201000000001,John Doe'], 'Hi {name}!');
Registration Shortcode
Enable "Enable OTP Verification on Registration" in /fanzly, then place [fanzly_register_otp] in your registration view (via ParseFanzlyShortcodes middleware or {!! fanzly_shortcode('[fanzly_register_otp]') !!}).
Validate the verified phone token on form submission:
use Fanzly\WhatsApp\Laravel\Rules\FanzlyOtpVerified; $request->validate([ 'fanzly_otp_token' => [new FanzlyOtpVerified()], ]);
Artisan CLI Diagnostics
php artisan fanzly:test php artisan fanzly:test +201000000000
License
The MIT License (MIT). See LICENSE for details.