bsg / php-sdk-v1
Comprehensive API for sending SMS, Viber messages, HLR/MNP requests and service management
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
README
Comprehensive API for sending SMS, Viber messages, HLR/MNP requests and service management
For more information, please visit https://bsg.world.
Installation
composer require bsgworld/php-sdk-v1
Requirements
- PHP 7.4 or later
- Guzzle HTTP client (installed automatically)
Getting Started
Please follow the installation procedure and then run the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization: ApiKeyAuth $config = BSG\Api\V1\Configuration::getDefaultConfiguration()->setApiKey('X-API-KEY', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = BSG\Api\V1\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-KEY', 'Bearer'); $apiInstance = new BSG\Api\V1\Api\SMSMessagingApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $sms_price_check_request = new \BSG\Api\V1\Model\SmsPriceCheckRequest([ 'destination' => 'phone', 'msisdn' => '380953227271', 'originator' => 'BSG', 'body' => 'Hello! This is a test message for price calculation.', 'transliterate' => true, ]); try { $result = $apiInstance->smsCheckPrice($sms_price_check_request); print_r($result); } catch (Exception $e) { echo 'Exception when calling SMSMessagingApi->smsCheckPrice: ', $e->getMessage(), PHP_EOL; }
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| sms_price_check_request | \BSG\Api\V1\Model\SmsPriceCheckRequest |
Return type
\BSG\Api\V1\Model\SmsPriceCheckResponse
Authorization
HTTP request headers
- Content-Type:
application/json - Accept:
application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
smsCheckPricePut()
smsCheckPricePut($sms_price_check_request): \BSG\Api\V1\Model\SmsPriceCheckResponse
Check SMS price (PUT)
Calculate SMS price without sending using PUT method
Example
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization: ApiKeyAuth $config = BSG\Api\V1\Configuration::getDefaultConfiguration()->setApiKey('X-API-KEY', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = BSG\Api\V1\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-KEY', 'Bearer'); $apiInstance = new BSG\Api\V1\Api\SMSMessagingApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $sms_price_check_request = new \BSG\Api\V1\Model\SmsPriceCheckRequest([ 'destination' => 'phone', 'msisdn' => '380953227271', 'originator' => 'BSG', 'body' => 'Hello! This is a test message for price calculation.', 'transliterate' => true, ]); try { $result = $apiInstance->smsCheckPricePut($sms_price_check_request); print_r($result); } catch (Exception $e) { echo 'Exception when calling SMSMessagingApi->smsCheckPricePut: ', $e->getMessage(), PHP_EOL; }
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| sms_price_check_request | \BSG\Api\V1\Model\SmsPriceCheckRequest |
Return type
\BSG\Api\V1\Model\SmsPriceCheckResponse
Authorization
HTTP request headers
- Content-Type:
application/json - Accept:
application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
smsCreateObjects()
smsCreateObjects($sms_create_request): \BSG\Api\V1\Model\SmsCreateResponse
Send SMS message
Send SMS message to one or multiple recipients
Example
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization: ApiKeyAuth $config = BSG\Api\V1\Configuration::getDefaultConfiguration()->setApiKey('X-API-KEY', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = BSG\Api\V1\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-API-KEY', 'Bearer'); $apiInstance = new BSG\Api\V1\Api\SMSMessagingApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $sms_create_request = new \BSG\Api\V1\Model\SmsCreateRequest([ 'destination' => 'phone', 'msisdn' => '380953227271', 'originator' => 'testsms', 'body' => 'k TEST Hello12 SMS 1115222', 'reference' => '1737033400123', 'validity' => 72, 'callback_url' => 'https://webhook.site/wh-delivery-reports', '2way' => 0, 'transliterate' => false, ]); try { $result = $apiInstance->smsCreateObjects($sms_create_request); print_r($result); } catch (Exception $e) { echo 'Exception when calling SMSMessagingApi->smsCreateObjects: ', $e->getMessage(), PHP_EOL; }
Endpoints
All URIs are relative to https://api.sms-service.local
| Class | Method | HTTP request | Description |
|---|---|---|---|
| AccountManagementApi | commonGetBalance | GET /rest/common/balance | Get account balance |
| AccountManagementApi | commonGetBalancePost | POST /rest/common/balance | Get account balance (POST) |
| CommonBalanceApi | commonGetBalance | GET /rest/common/balance | Get account balance |
| CommonBalancePostApi | commonGetBalancePost | POST /rest/common/balance | Get account balance (POST) |
| HLRNumberVerificationApi | hlrCreateObjects | POST /rest/hlr/create | Perform HLR lookup |
| HLRNumberVerificationApi | hlrCreateObjectsPut | PUT /rest/hlr/create | Perform HLR lookup (PUT) |
| HLRNumberVerificationApi | hlrCreateObjectsSync | POST /rest/hlr/check | Perform synchronous HLR lookup |
| HLRNumberVerificationApi | hlrCreateObjectsSyncPut | PUT /rest/hlr/check | Perform synchronous HLR lookup (PUT) |
| HLRNumberVerificationApi | hlrGetBalance | GET /rest/hlr/balance | Get account balance |
| HLRNumberVerificationApi | hlrGetBalancePost | POST /rest/hlr/balance | Get account balance |
| HLRNumberVerificationApi | hlrGetPrices | GET /rest/hlr/prices | Get HLR pricing |
| HLRNumberVerificationApi | hlrGetStatusByExtId | GET /rest/hlr/reference/{reference} | Get HLR result by reference |
| HLRNumberVerificationApi | hlrGetStatusById | GET /rest/hlr/{id} | Get HLR result by ID |
| HlrBalanceApi | hlrGetBalance | GET /rest/hlr/balance | Get account balance |
| HlrBalancePostApi | hlrGetBalancePost | POST /rest/hlr/balance | Get account balance |
| HlrCreateApi | hlrCreateObjects | POST /rest/hlr/create | Perform HLR lookup |
| HlrCreatePutApi | hlrCreateObjectsPut | PUT /rest/hlr/create | Perform HLR lookup (PUT) |
| HlrCreateSyncApi | hlrCreateObjectsSync | POST /rest/hlr/check | Perform synchronous HLR lookup |
| HlrCreateSyncPutApi | hlrCreateObjectsSyncPut | PUT /rest/hlr/check | Perform synchronous HLR lookup (PUT) |
| HlrPricesApi | hlrGetPrices | GET /rest/hlr/prices | Get HLR pricing |
| HlrStatusByIdApi | hlrGetStatusById | GET /rest/hlr/{id} | Get HLR result by ID |
| HlrStatusByRefApi | hlrGetStatusByExtId | GET /rest/hlr/reference/{reference} | Get HLR result by reference |
| MNPPortabilityApi | mnpCreateObjects | POST /rest/mnp/create | Perform MNP lookup |
| MNPPortabilityApi | mnpCreateObjectsPut | PUT /rest/mnp/create | Perform MNP lookup (PUT) |
| MNPPortabilityApi | mnpGetPrices | GET /rest/mnp/prices | Get MNP pricing |
| MNPPortabilityApi | mnpGetStatusByExtId | GET /rest/mnp/reference/{reference} | Get MNP result by reference |
| MNPPortabilityApi | mnpGetStatusById | GET /rest/mnp/{id} | Get MNP result by ID |
| MNPSyncApi | mnpSyncCreateObjects | POST /rest/mnp-sync/create | Perform synchronous MNP lookup |
| MNPSyncApi | mnpSyncCreateObjectsPut | PUT /rest/mnp-sync/create | Perform synchronous MNP lookup (PUT) |
| MNPSyncApi | mnpSyncGetPrices | GET /rest/mnp-sync/prices | Get MNP pricing |
| MnpCreateApi | mnpCreateObjects | POST /rest/mnp/create | Perform MNP lookup |
| MnpCreatePutApi | mnpCreateObjectsPut | PUT /rest/mnp/create | Perform MNP lookup (PUT) |
| MnpPricesApi | mnpGetPrices | GET /rest/mnp/prices | Get MNP pricing |
| MnpStatusByIdApi | mnpGetStatusById | GET /rest/mnp/{id} | Get MNP result by ID |
| MnpStatusByRefApi | mnpGetStatusByExtId | GET /rest/mnp/reference/{reference} | Get MNP result by reference |
| MnpSyncCreateApi | mnpSyncCreateObjects | POST /rest/mnp-sync/create | Perform synchronous MNP lookup |
| MnpSyncCreatePutApi | mnpSyncCreateObjectsPut | PUT /rest/mnp-sync/create | Perform synchronous MNP lookup (PUT) |
| MnpSyncPricesApi | mnpSyncGetPrices | GET /rest/mnp-sync/prices | Get MNP pricing |
| SMSMessagingApi | smsCheckPrice | POST /rest/sms/price | Check SMS price |
| SMSMessagingApi | smsCheckPricePut | PUT /rest/sms/price | Check SMS price (PUT) |
| SMSMessagingApi | smsCreateObjects | POST /rest/sms/create | Send SMS message |
| SMSMessagingApi | smsCreateObjectsPut | PUT /rest/sms/create | Send SMS message (PUT) |
| SMSMessagingApi | smsGet2WayIncoming | GET /rest/sms/2wayIncoming | Get 2-way incoming messages |
| SMSMessagingApi | smsGet2WaySenders | GET /rest/sms/2waySenders | Get 2-way senders |
| SMSMessagingApi | smsGetBalance | GET /rest/sms/balance | Get account balance |
| SMSMessagingApi | smsGetBalancePost | POST /rest/sms/balance | Get account balance |
| SMSMessagingApi | smsGetMassStatus | POST /rest/sms/getStatus | Get status for multiple SMS messages |
| SMSMessagingApi | smsGetPrices | GET /rest/sms/prices | Get SMS pricing |
| SMSMessagingApi | smsGetStatusByExtId | GET /rest/sms/reference/{reference} | Get SMS status by reference |
| SMSMessagingApi | smsGetStatusById | GET /rest/sms/{id} | Get SMS status by ID |
| SMSMessagingApi | smsGetTaskStatus | GET /rest/sms/task/{taskId} | Get task status |
| Sms2wayIncomingApi | smsGet2WayIncoming | GET /rest/sms/2wayIncoming | Get 2-way incoming messages |
| Sms2waySendersApi | smsGet2WaySenders | GET /rest/sms/2waySenders | Get 2-way senders |
| SmsBalanceApi | smsGetBalance | GET /rest/sms/balance | Get account balance |
| SmsBalancePostApi | smsGetBalancePost | POST /rest/sms/balance | Get account balance |
| SmsCheckPriceApi | smsCheckPrice | POST /rest/sms/price | Check SMS price |
| SmsCheckPricePutApi | smsCheckPricePut | PUT /rest/sms/price | Check SMS price (PUT) |
| SmsCreateApi | smsCreateObjects | POST /rest/sms/create | Send SMS message |
| SmsCreatePutApi | smsCreateObjectsPut | PUT /rest/sms/create | Send SMS message (PUT) |
| SmsMassStatusApi | smsGetMassStatus | POST /rest/sms/getStatus | Get status for multiple SMS messages |
| SmsPricesApi | smsGetPrices | GET /rest/sms/prices | Get SMS pricing |
| SmsStatusByIdApi | smsGetStatusById | GET /rest/sms/{id} | Get SMS status by ID |
| SmsStatusByRefApi | smsGetStatusByExtId | GET /rest/sms/reference/{reference} | Get SMS status by reference |
| SmsTaskStatusApi | smsGetTaskStatus | GET /rest/sms/task/{taskId} | Get task status |
| StatDeleteFileApi | statDeleteFile | DELETE /rest/stat/file/{id} | Delete export file |
| StatGetFileApi | statGetFile | GET /rest/stat/file/id/{id}/format/{format} | Download export file |
| StatListExportsApi | statGetList | GET /rest/stat/list | List export jobs |
| StatRequestExportApi | statRequestExport | POST /rest/stat/create | Request data export |
| StatRequestExportPutApi | statRequestExportPut | PUT /rest/stat/create | Request data export (PUT) |
| StatisticsExportsApi | statDeleteFile | DELETE /rest/stat/file/{id} | Delete export file |
| StatisticsExportsApi | statGetFile | GET /rest/stat/file/id/{id}/format/{format} | Download export file |
| StatisticsExportsApi | statGetList | GET /rest/stat/list | List export jobs |
| StatisticsExportsApi | statRequestExport | POST /rest/stat/create | Request data export |
| StatisticsExportsApi | statRequestExportPut | PUT /rest/stat/create | Request data export (PUT) |
| ViberCheckPriceApi | viberCheckPrice | POST /rest/viber/price | Check Viber campaign price |
| ViberCheckPricePutApi | viberCheckPricePut | PUT /rest/viber/price | Check Viber campaign price (PUT) |
| ViberCreateApi | viberCreateObjects | POST /rest/viber/create | Send Viber message |
| ViberCreatePutApi | viberCreateObjectsPut | PUT /rest/viber/create | Send Viber message (PUT) |
| ViberMessagingApi | viberCheckPrice | POST /rest/viber/price | Check Viber campaign price |
| ViberMessagingApi | viberCheckPricePut | PUT /rest/viber/price | Check Viber campaign price (PUT) |
| ViberMessagingApi | viberCreateObjects | POST /rest/viber/create | Send Viber message |
| ViberMessagingApi | viberCreateObjectsPut | PUT /rest/viber/create | Send Viber message (PUT) |
| ViberMessagingApi | viberGetPrices | GET /rest/viber/prices/{tariff} | Get Viber pricing |
| ViberMessagingApi | viberGetStatusByExtId | GET /rest/viber/reference/{reference} | Get Viber status by reference |
| ViberMessagingApi | viberGetStatusById | GET /rest/viber/{id} | Get Viber status by ID |
| ViberPricesApi | viberGetPrices | GET /rest/viber/prices/{tariff} | Get Viber pricing |
| ViberStatusByIdApi | viberGetStatusById | GET /rest/viber/{id} | Get Viber status by ID |
| ViberStatusByRefApi | viberGetStatusByExtId | GET /rest/viber/reference/{reference} | Get Viber status by reference |
Models
- BalanceResponse
- ErrorResponse
- ExportCreateRequest
- ExportCreateResponse
- ExportListItem
- ExportListResponse
- HlrCreateRequest
- HlrCreateResponse
- HlrCreateResultItem
- HlrDetails
- HlrPriceItem
- HlrPricesResponse
- HlrRequestItem
- HlrSingleRequest
- HlrStatusResponse
- HlrSyncRequest
- HlrSyncResponse
- HttpError500Response
- MnpBatchItem
- MnpBatchRequest
- MnpCreateRequest
- MnpCreateResponse
- MnpCreateResultItem
- MnpInfo
- MnpPriceItem
- MnpPricesResponse
- MnpSingleRequest
- MnpStatusResponse
- Sms2WayIncomingMessage
- Sms2WayIncomingResponse
- SmsBalanceResponse
- SmsCreateOtpResultItem
- SmsCreateRequest
- SmsCreateResponse
- SmsCreateResultItem
- SmsCreateSingleResult
- SmsIndividualCreateRequest
- SmsIndividualPhoneItem
- SmsMassStatusItem
- SmsMassStatusRequest
- SmsMassStatusResponse
- SmsMultipleCreateRequest
- SmsMultipleResponse
- SmsOtpCreateRequest
- SmsPhoneItem
- SmsPriceCheckMultipleRequest
- SmsPriceCheckPhoneItem
- SmsPriceCheckRequest
- SmsPriceCheckResponse
- SmsPriceCheckSingleRequest
- SmsPriceInfo
- SmsPricesListResponse
- SmsSingleCreateRequest
- SmsSingleResponse
- SmsStatusResponse
- SmsTaskResponse
- SmsTaskStatusResponse
- SuccessResponse
- ViberAltRouteItem
- ViberAltRouteMessage
- ViberChannelOptions
- ViberCreateRequest
- ViberCreateResponse
- ViberCreateResultItem
- ViberMessageItem
- ViberMessageOptions
- ViberPriceCheckMessageItem
- ViberPriceCheckRequest
- ViberPriceCheckResponse
- ViberPriceItem
- ViberPricesResponse
- ViberRecipient
- ViberSmsFallback
- ViberStatusResponse
Authorization
Authentication schemes defined for the API:
ApiKeyAuth
- Type: API key
- API key parameter name: X-API-KEY
- Location: HTTP header
Tests
To run the tests, use:
composer install vendor/bin/phpunit
Author
About this package
This PHP package is automatically generated by the OpenAPI Generator project:
- API version:
1.0.0- Generator version:
7.12.0
- Generator version:
- Build package:
org.openapitools.codegen.languages.PhpClientCodegen