Download the PHP package am-naguib/am-sender without Composer
On this page you can find all versions of the php package am-naguib/am-sender. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package am-sender
AM-Sender Laravel Package
A Laravel package for integrating with the AM-Sender API (https://am-sender.com/api) to send WhatsApp messages programmatically.
Features
- Easy integration with Laravel 10+
- Auto-discovery support
- Facade-based API
- Comprehensive error handling
- Configurable HTTP client with retry logic
- Device management
- Message sending with support for images
Installation
Install the package via Composer:
The package will be automatically discovered by Laravel.
Configuration
Publish the configuration file:
This will create a config/am-sender.php
file. Add your AM-Sender credentials to your .env
file:
Usage
Using the Facade
Using Dependency Injection
API Methods
listDevices()
Retrieve all devices associated with your account.
Returns:
createDevice(string $name)
Create a new device.
Returns:
send(array $payload)
Send a message to one or more recipients.
Parameters:
message
(required): The message text to sendreceivers
(required): Array of phone numbers (with country code)device_ids
(required): Array of device IDs to send fromdelay_time
(optional): Delay between messages in secondsimage
(optional): URL of image to send with the message
Returns:
Input Validation
The package automatically validates all input data before sending requests to the API. This helps catch errors early and provides clear feedback.
Validation Rules
Device Name Validation:
- Required: Cannot be empty
- Length: 3-50 characters
- Characters: Letters, numbers, spaces, hyphens, and underscores only
Message Validation:
- Required: Cannot be empty
- Length: 3-4096 characters
Phone Number Validation:
- Format: Flexible format - accepts any phone number format
- Length: 5-20 characters
- Characters: Numbers, spaces, hyphens, parentheses, and plus sign allowed
- Auto-Cleaning: Empty phone numbers are automatically filtered out
- No Duplicates: Duplicate numbers are automatically detected
Device IDs Validation:
- Required: At least one device ID
- Limit: Maximum 10 devices per request
- Length: 3-100 characters per device ID
- No Duplicates: Duplicate device IDs are detected
Optional Fields:
- delay_time: 0-3600 seconds (1 hour max)
- image: Valid URL pointing to image file (jpg, jpeg, png, gif, webp, bmp)
Validation Examples
Image Handling
The package provides comprehensive image URL validation and helpful error messages for image-related issues.
Image URL Requirements:
- Must be publicly accessible (no localhost or private URLs)
- Must use HTTP or HTTPS protocol
- Should point to a valid image file (jpg, jpeg, png, gif, webp, bmp, svg)
- Maximum URL length: 2048 characters
Common Image Issues and Solutions:
Image Error Messages:
Exception Handling
The package provides specific exception classes for different error scenarios:
AMSenderException
- Base exception classUserNotFoundException
- User not foundSubscriptionExpiredException
- Subscription has expiredDeviceNotFoundException
- Device not found or inactiveInvalidImageException
- Invalid or inaccessible image URLAuthKeyNotValidException
- Invalid authentication keyLimitExceededException
- API limits exceededValidationException
- Input validation errors (422 status code)
Configuration Options
The config/am-sender.php
file provides several configuration options:
Best Practices
Input Sanitization
The package automatically trims whitespace from all string inputs and validates data formats. However, you should still sanitize your inputs before passing them to the package.
Error Handling
Always wrap your API calls in try-catch blocks to handle both validation errors and API errors gracefully:
Phone Number Formatting
The package accepts flexible phone number formats and automatically filters out empty numbers:
Batch Processing
For large recipient lists, consider breaking them into smaller batches:
Requirements
- PHP 8.1 or higher
- Laravel 10.0 or higher
- Guzzle HTTP client
License
This package is open-sourced software licensed under the MIT license.
Support
For support and questions about the AM-Sender API, please visit https://am-sender.com.
For package-specific issues, please create an issue in the repository.