https://github.com/buibr/budget-sms-php
https://github.com/buibr/budget-sms-php
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/buibr/budget-sms-php
- Owner: buibr
- Created: 2019-04-05T07:45:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-07T08:26:30.000Z (almost 3 years ago)
- Last Synced: 2024-11-20T17:15:51.788Z (over 1 year ago)
- Language: PHP
- Size: 43 KB
- Stars: 4
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# budget-sms-php
Install with composer
```terminal
composer require buibr/budget-sms-php
```
### Usage:
###### Example 1:
```php
$budget = new \buibr\Budget\BudgetSMS( [
'username'=>'xxx',
'userid'=> 'xxx',
'handle'=>'xxx',
]);
// sender name
$budget->setSender("Test");
// add recepient
$budget->setRecipient('+38971xxxxxx');
// add message
$budget->setMessage('Testing the provider');
// Send the message
$send = $budget->send();
```
###### Example 2:
```php
use buibr\Budget\BudgetSMS;
$budget = new BudgetSMS( [
'username'=>'xxx',
'userid'=> 'xxx',
'handle'=>'xxx',
'from'=>'Test',
'price'=> 1, // optional
'mccmnc'=> 1, // optional
'credit'=> 1, // optional
]);
$send = $budget->send( '+38971xxxxxx', 'message content' );
```
### Response examples:
###### Success:
```php
buibr\Budget\BudgetResponse Object
(
[code] => 200
[type] => text/plain; charset=UTF-8
[time] => 0.494388
[status] => 1
[response] => Array
(
[transaction] => 76208843
[price] => 0.02
[time] => 1
[mccmnc] => 29401
[credit] => 590.5892
)
[data] => OK 76208843 0.02 1 29401 590.5892
)
```
###### Error:
```php
buibr\Budget\BudgetResponse Object
(
[code] => 200
[type] => text/plain; charset=UTF-8
[time] => 0.32309
[status] =>
[response] => SMS message text is empty
[data] => ERR 2001
)
```
### Push DLR Handler (webhook to accept requests):
###### Request:
```php
$budget = new BudgetSMS;
$dlr = $budget->pushDlr( $payload );
```
###### Response:
```php
Array
(
[code] =>
[type] =>
[time] =>
[status] =>
[smsid] => xxx
[sms_code] => 7
[sms_message] => SMSC error, message could not be processed
)
```
### Pull DLR Handler:
###### Request
```php
$budget = new BudgetSMS( [
'username'=>'xxx',
'userid'=> 'xxx',
'handle'=>'xxx',
]);
$dlr = $budget->pullDLR('xxxx');
```
###### Response
```php
Array
(
[code] => 200
[type] => text/html; charset=UTF-8
[time] => 0.261374
[status] =>
[smsid] => xxx
[sms_code] => 8
[sms_message] => Message not allowed
[data] => OK 8
)
```