- Notifications
You must be signed in to change notification settings - Fork5
The official PHP API Client for seven.io
License
seven-io/php-client
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
The official PHP SDK for the seven.io SMS Gateway API
Documentation •API Reference •Support •Dashboard
composer require seven.io/api
Download the latest release asZIP file and include it in your project.
<?phprequire'vendor/autoload.php';useSeven\Api\Client;useSeven\Api\Resource\Sms\SmsParams;useSeven\Api\Resource\Sms\SmsResource;// Initialize the client with your API key$client =newClient('YOUR_API_KEY');// Create SMS resource$smsResource =newSmsResource($client);// Send SMS$response =$smsResource->dispatch(newSmsParams('Hello from seven.io!','+491234567890'));echo"SMS sent successfully! ID:" .$response->getMessages()[0]->getId();
- ✅ Send SMS to single or multiple recipients
- ✅ Bulk SMS support
- ✅ Flash SMS
- ✅ Unicode support
- ✅ Delivery reports
- ✅ Schedule messages
- ✅ Text-to-Speech calls
- ✅ Voice message broadcasts
- ✅ HLR (Home Location Register) lookup
- ✅ Number format validation
- ✅ Carrier information
- ✅ Number portability check
- ✅ Balance inquiry
- ✅ Pricing information
- ✅ Webhook management
- ✅ Contact management
- ✅ Analytics & Journal
$params = (newSmsParams('Your message here','+491234567890')) ->setFrom('YourBrand') ->setUnicode(true) ->setFlash(false);$response =$smsResource->dispatch($params);
$params =newSmsParams('Bulk message to multiple recipients', ['+491234567890','+491234567891','+491234567892']);$response =$smsResource->dispatch($params);
$params = (newSmsParams('Scheduled message','+491234567890')) ->setDelay(new \DateTime('+1 hour'));$response =$smsResource->dispatch($params);
useSeven\Api\Resource\Lookup\LookupResource;$lookupResource =newLookupResource($client);$results =$lookupResource->hlr('+491234567890');$hlr =$results[0];echo"Current Carrier:" .$hlr->getCurrentCarrier()->getName() ."\n";echo"Country:" .$hlr->getCountryName() ."\n";echo"Reachable:" .$hlr->getReachable() ."\n";echo"Ported:" .$hlr->getPorted() ."\n";
useSeven\Api\Resource\Balance\BalanceResource;$balanceResource =newBalanceResource($client);$balance =$balanceResource->get();echo"Current balance: €" .$balance->getAmount();
useSeven\Api\Resource\Voice\VoiceResource;useSeven\Api\Resource\Voice\VoiceParams;$voiceResource =newVoiceResource($client);$params =newVoiceParams('+491234567890','Hello, this is a test call');$response =$voiceResource->call($params);
$client =newClient( apiKey:'YOUR_API_KEY', signingSecret:'YOUR_SIGNING_SECRET');
The SDK provides specific exceptions for different API error conditions:
useSeven\Api\Exception\ApiException;useSeven\Api\Exception\InvalidApiKeyException;useSeven\Api\Exception\MissingAccessRightsException;useSeven\Api\Exception\ForbiddenIpException;try {$response =$smsResource->dispatch($params);}catch (InvalidApiKeyException$e) {echo"Invalid API key provided";}catch (MissingAccessRightsException$e) {echo"Missing access rights for this operation";}catch (ForbiddenIpException$e) {echo"Your IP address is not allowed";}catch (ApiException$e) {// Handles all other API error codes (100-903)// Common codes: 500 = Insufficient credit, 201 = Invalid sender, 202 = Invalid recipientecho"API Error:" .$e->getMessage() ." (Code:" .$e->getCode() .")";}catch (\Exception$e) {echo"Error:" .$e->getMessage();}
| Code | Description |
|---|---|
| 100 | SMS accepted and being sent |
| 101 | Sending to at least one recipient failed |
| 201 | Invalid sender |
| 202 | Invalid recipient number |
| 301-305 | Parameter validation errors |
| 500 | Insufficient account credit |
| 600 | Sending error occurred |
| 900-903 | Authentication/authorization errors |
Run the test suite with your API credentials:
# Using production API keySEVEN_API_KEY=your_api_key php vendor/bin/phpunit tests# Using sandbox API keySEVEN_API_KEY_SANDBOX=your_sandbox_key php vendor/bin/phpunit tests
# Test only SMS functionalityphp vendor/bin/phpunit tests/SmsTest.php# Test with verbose outputphp vendor/bin/phpunit tests --verbose
The SDK provides access to all seven.io API endpoints:
| Resource | Description |
|---|---|
AnalyticsResource | Analytics and statistics |
BalanceResource | Account balance |
ContactsResource | Contact management |
HooksResource | Webhook management |
JournalResource | Message history |
LookupResource | Number lookup & validation |
PricingResource | Pricing information |
RcsResource | RCS messaging |
SmsResource | SMS messaging |
StatusResource | Delivery reports |
SubaccountsResource | Subaccount management |
ValidateForVoiceResource | Voice number validation |
VoiceResource | Voice calls |
| Variable | Description |
|---|---|
SEVEN_API_KEY | Your production API key |
SEVEN_API_KEY_SANDBOX | Your sandbox API key for testing |
SEVEN_SIGNING_SECRET | Webhook signing secret |
SEVEN_TEST_RECIPIENT | Custom recipient phone number for tests (default:491716992343) |
- PHP 8.2 or higher
- Composer (for installation)
- ext-curl
- ext-json
We welcome contributions! Please see ourContributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see theLICENSE file for details.
Made with ❤️ byseven.io
About
The official PHP API Client for seven.io
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.