Skip to content

Commit

Permalink
chore(SMS): update Readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
enigma972 committed Nov 15, 2021
1 parent 2b2d8b1 commit 5f6d6f0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 42 deletions.
78 changes: 37 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,57 @@ Orange APIs Client with Token Caching
You need to have composer installed in your computer before doing this

```bash
composer require informagenie/orange-sms
composer require enigma972/orange-api-client
```

## Quick setup
## Quick setup and Basic example (SMS)

Get `client_id` and `client_secret` [here](https://developer.orange.com/myapps/) or [follow guide](https://informagenie.com/3141/envoyer-sms-orange-sms-api/)
Get `client_id` and `client_secret` [here](https://developer.orange.com/myapps/)

All examples [here](https://github.com/enigma972/orange-api-client/tree/main/examples/Sms)

```php
<?php
require_once __DIR__.'/vendor/autoload.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;

use Informagenie\OrangeSDK;
$cache = new FilesystemAdapter();
$client = new Client($cache, 'YOUR-CLIENT-ID', 'YOUR-CLIENT-SECRET');

$credentials = [
'client_id' => 'your_client_id',
'client_secret' => 'your_client_secret'
];
$sms = new Sms($client);

/*
You can use directly authorization header instead of client_id and client_secret
$credentials = [
'authorization_header' => 'Basic xxx...',
];
*/
$message = new Message();
$message
->content('Hello world, via Orange SMS API.')
->from(243899999999)
->as('Enigma972')
->to(243899999999)
;

$sms = new OrangeSDK($credentials);
$response = $sms->doSend($message);

$response = $sms->message('Hello world !')
->from(243820000000) // Sender phone's number
->as('Informagenie') // Sender's name (optional)
->to(2439000000000) // Recipiant phone's number
->send();
dd($response->toArray());

```
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
)
)
^ array:1 [▼
"outboundSMSMessageRequest" => array:4 [▼
"address" => array:1 [▼
0 => "tel:+243899999999"
]
"senderAddress" => "tel:+243899999999"
"outboundSMSTextMessage" => array:1 [▼
"message" => "Hello world, via Orange SMS API."
]
"resourceURL" => "https://api.orange.com/smsmessaging/v1/outbound/tel:+243899999999/requests/2fdd2d6e-c155-43d3-97ef-1dce0dc648d5"
]
]
```

Also read [here](https://github.com/ismaeltoe/osms) and [here](https://github.com/informagenie/orange-sms).
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "enigma972/orange-api-client",
"description": "Orange APIs Client",
"description": "PHP SDK for Orange APIs Client with Token Caching",
"type": "library",
"keywords": [
"php", "api", "sms", "client", "http client", "json", "requests", "rest",
"restful", "web service", "orange", "cache"
],
"homepage": "https://github.com/enigma972/orange-api-client",
"license": "MIT",
"authors": [
{
Expand Down

0 comments on commit 5f6d6f0

Please sign in to comment.