-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor Token Authentication add examples
- Loading branch information
Showing
17 changed files
with
939 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,66 @@ | ||
# Orange API Client (SDK) | ||
Orange APIs Client with Token Caching | ||
|
||
## Installation | ||
|
||
You need to have composer installed in your computer before doing this | ||
|
||
```bash | ||
composer require informagenie/orange-sms | ||
``` | ||
|
||
## Quick setup | ||
|
||
Get `client_id` and `client_secret` [here](https://developer.orange.com/myapps/) or [follow guide](https://informagenie.com/3141/envoyer-sms-orange-sms-api/) | ||
|
||
```php | ||
<?php | ||
require_once __DIR__.'/vendor/autoload.php'; | ||
|
||
use Informagenie\OrangeSDK; | ||
|
||
$credentials = [ | ||
'client_id' => 'your_client_id', | ||
'client_secret' => 'your_client_secret' | ||
]; | ||
|
||
/* | ||
You can use directly authorization header instead of client_id and client_secret | ||
$credentials = [ | ||
'authorization_header' => 'Basic xxx...', | ||
]; | ||
*/ | ||
|
||
$sms = new OrangeSDK($credentials); | ||
|
||
$response = $sms->message('Hello world !') | ||
->from(243820000000) // Sender phone's number | ||
->as('Informagenie') // Sender's name (optional) | ||
->to(2439000000000) // Recipiant phone's number | ||
->send(); | ||
|
||
``` | ||
If all is ok, $response should be like this : | ||
|
||
``` | ||
stdClass Object | ||
( | ||
[outboundSMSMessageRequest] => stdClass Object | ||
( | ||
[address] => Array | ||
( | ||
[0] => tel:+243900000000 | ||
) | ||
[senderAddress] => tel:+243820000000 | ||
[senderName] => Informagenie | ||
[outboundSMSTextMessage] => stdClass Object | ||
( | ||
[message] => Hello World | ||
) | ||
[resourceURL] => https://api.orange.com/smsmessaging/v1/outbound/tel:+243820000000/requests/9d523078-1d3d-4c90-8984-7216e18deb97 | ||
) | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,5 +18,8 @@ | |
"psr-4": { | ||
"OrangeApiClient\\": "src/" | ||
} | ||
}, | ||
"require-dev": { | ||
"symfony/var-dumper": "^5.3" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
require_once './../../vendor/autoload.php'; | ||
|
||
use OrangeApiClient\Service\Sms\Sms; | ||
use Symfony\Component\Cache\Adapter\FilesystemAdapter; | ||
use OrangeApiClient\Client; | ||
|
||
$cache = new FilesystemAdapter(); | ||
$client = new Client($cache, 'YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET'); | ||
|
||
$sms = new Sms($client); | ||
|
||
$response = $sms->getContracts([ | ||
'contry' => 'CONTRY-CODE', | ||
]); | ||
|
||
dd($response->toArray()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
require_once './../../vendor/autoload.php'; | ||
|
||
use OrangeApiClient\Service\Sms\Sms; | ||
use Symfony\Component\Cache\Adapter\FilesystemAdapter; | ||
use OrangeApiClient\Client; | ||
|
||
$cache = new FilesystemAdapter(); | ||
$client = new Client($cache, 'YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET'); | ||
|
||
$sms = new Sms($client); | ||
|
||
$response = $sms->getPurchaseOrders([ | ||
'contry' => 'CONTRY-CODE', | ||
]); | ||
|
||
dd($response->toArray()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
require_once './../../vendor/autoload.php'; | ||
|
||
use OrangeApiClient\Service\Sms\Sms; | ||
use Symfony\Component\Cache\Adapter\FilesystemAdapter; | ||
use OrangeApiClient\Client; | ||
|
||
$cache = new FilesystemAdapter(); | ||
$client = new Client($cache, 'YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET'); | ||
|
||
$sms = new Sms($client); | ||
|
||
$response = $sms->getStatistics([ | ||
'contry' => 'CONTRY-CODE', | ||
'appid' => 'APP-ID', | ||
]); | ||
|
||
dd($response->toArray()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
require_once './../../vendor/autoload.php'; | ||
|
||
use Symfony\Component\Cache\Adapter\FilesystemAdapter; | ||
use OrangeApiClient\Client; | ||
|
||
$cache = new FilesystemAdapter(); | ||
$client = new Client($cache, 'YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET'); | ||
|
||
$token = $client->getAccessToken(); | ||
|
||
dd($token); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
require_once './../../vendor/autoload.php'; | ||
|
||
use OrangeApiClient\Service\Sms\Sms; | ||
use Symfony\Component\Cache\Adapter\FilesystemAdapter; | ||
use OrangeApiClient\Client; | ||
use OrangeApiClient\Service\Sms\Message; | ||
|
||
$cache = new FilesystemAdapter(); | ||
$client = new Client($cache, 'YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET'); | ||
|
||
$sms = new Sms($client); | ||
|
||
$message = new Message(); | ||
$message | ||
->content('Hello world, via Orange SMS API.') | ||
->from(243899999999) | ||
// ->as('Lussi') | ||
->to(243899999999) | ||
; | ||
|
||
$response = $sms->doSend($message); | ||
|
||
dd($response->toArray()); |
Oops, something went wrong.