mep de la gw sms !
This commit is contained in:
@@ -38,6 +38,7 @@ services:
|
||||
- icons:/var/www/htdocs/images/
|
||||
- lang:/var/www/lang/
|
||||
- ./UIHooks:/var/www/kaz/
|
||||
- ./smsapi-kaz.inc.php:/var/www/lib/smsapi-kaz.inc.php:ro
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.${ldapUIName}.rule=Host(`${ldapUIHost}.${domain}`)"
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
//utilisable avec https://github.com/capcom6/android-sms-gateway
|
||||
class KazSMS
|
||||
{
|
||||
private $sms_api_url;
|
||||
private $sms_api_user;
|
||||
private $sms_api_password;
|
||||
|
||||
public function __construct($sms_api_url, $sms_api_user, $sms_api_password)
|
||||
{
|
||||
$this->sms_api_url = $sms_api_url;
|
||||
$this->sms_api_user = $sms_api_user;
|
||||
$this->sms_api_password = $sms_api_password;
|
||||
}
|
||||
|
||||
public function send_sms_by_api($sms, $sms_message)
|
||||
{
|
||||
$data = json_encode([
|
||||
'textMessage' => [
|
||||
'text' => $sms_message
|
||||
],
|
||||
'phoneNumbers' => [
|
||||
$sms
|
||||
]
|
||||
]);
|
||||
|
||||
$ch = curl_init($this->sms_api_url);
|
||||
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
|
||||
CURLOPT_USERPWD => $this->sms_api_user . ':' . $this->sms_api_password,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data)
|
||||
],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CONNECTTIMEOUT => 5,
|
||||
CURLOPT_TIMEOUT => 15
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
if ($error) {
|
||||
error_log("KazSMS cURL error: $error");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($http_code < 200 || $http_code >= 300) {
|
||||
error_log("KazSMS HTTP error $http_code: $response");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,3 +7,7 @@ LDAPUI_ADMIN_BIND_PWD=@@pass@@ldapui@@p@@
|
||||
LDAPUI_IGNORE_CERT_ERRORS=TRUE
|
||||
LDAPUI_PASSWORD=@@pass@@ldapuipass@@p@@
|
||||
LDAPUI_MM_ADMIN_TOKEN=@@crossvar@@mattermostAdmin_mattermost_token@@cv@@
|
||||
|
||||
SMS_API_URL=
|
||||
SMS_API_USER=
|
||||
SMS_API_PASSWORD=
|
||||
|
||||
Reference in New Issue
Block a user