-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathorange.php
More file actions
69 lines (63 loc) · 2.05 KB
/
orange.php
File metadata and controls
69 lines (63 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Orange SMS Gateway
* @url https://developer.orange.com
* @author Titan Systems
*/
define("ORANGE_GATEWAY", [
"authorization" => "aSsJ6UtbdUnGgN67cV8qkGK262iBy75KkbZhVUbBY0etTCP8kF==", // Your orange authorization header, do not include the word "Basic"
"senderAddress" => "9620000", // Your sender address, do not add "+" in the beginning of the string
"senderName" => "OrangeGateway" // Your sender name
]);
return [
"send" => function ($phone, $message, &$system) {
/**
* Implement sending here
* @return bool:true
* @return bool:false
*/
try {
$getToken = json_decode($system->guzzle->post("https://api.orange.com/oauth/v3/token", [
"headers" => [
"Authorization" => "Basic " . ORANGE_GATEWAY["authorization"]
],
"form_params" => [
"grant_type" => "client_credentials"
],
"allow_redirects" => true,
"http_errors" => false
])->getBody()->getContents(), true);
if(isset($getToken["token_type"]) && $getToken["token_type"] == "Bearer"):
$send = $system->guzzle->post("https://api.orange.com/smsmessaging/v1/outbound/tel%3A%2B" . ORANGE_GATEWAY["senderAddress"] . "/requests", [
"headers" => [
"Authorization" => "Bearer {$getToken["access_token"]}"
],
"json" => [
"outboundSMSMessageRequest" => [
"address" => "tel:{$phone}",
"senderAddress" => "tel:+" . ORANGE_GATEWAY["senderAddress"],
"senderName" => ORANGE_GATEWAY["senderName"],
"outboundSMSTextMessage" => [
"message" => $message
]
]
],
"allow_redirects" => true,
"http_errors" => false
]);
return $send->getStatusCode() == 201 ? true : false;
else:
return false;
endif;
} catch(Exception $e){
return false;
}
},
"callback" => function ($request, &$system) {
/**
* Implement status callback here if gateway supports it
* @return array:MessageID
* @return array:Empty
*/
}
];