forked from solaymanhaider/notify-woosms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsms.php
48 lines (44 loc) · 1.95 KB
/
sms.php
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
<?php
function notify_woosms_send_sms($mobilenumber, $smsbodytext){
$options = get_option( 'notify_woosms_settings' );
$body = array(
'recipient' => $mobilenumber,
'sender' => $options['notify_woosms_api_mask'],
'body' => $smsbodytext,
'userid' => $options['notify_woosms_api_user_name'],
'password' => $options['notify_woosms_api_password']
);
$args = array(
'body' => $body,
'timeout' => '5',
'redirection' => '5',
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'cookies' => array()
);
if ($options['notify_woosms_select_provider'] == 'dianahost_psms') {
$response = wp_remote_post( 'https://psms.dianahost.com/api/sms/v1/send', $args );
} elseif ($options['notify_woosms_select_provider'] == 'dianahost_esms') {
$apikey = $options['notify_woosms_api_key'];
$response = wp_remote_post( 'http://esms.hostdokan.com/smsapi?api_key='.$apikey.'&type=text&contacts='.$mobilenumber.'&msg='.$smsbodytext.'&senderid='.$options['notify_woosms_api_mask'] );
} elseif ($options['notify_woosms_select_provider'] == 'dianahost_gsms') {
$apikey = $options['notify_woosms_api_key'];
$response = wp_remote_post( 'http://gsms.pw/smsapi?api_key='.$apikey.'&type=text&contacts='.$mobilenumber.'&msg='.$smsbodytext.'&senderid='.$options['notify_woosms_api_mask'] );
} elseif ($options['notify_woosms_select_provider'] == 'tiniyo') {
$url = 'https://api.tiniyo.com/v1/Account/' . $options['notify_woosms_api_user_name'] . '/Message'
$body = array(
'dst' => $mobilenumber,
'src' => $options['notify_woosms_api_src'],
'text' => $smsbodytext
);
$response = wp_remote_post( $url, array(
'body' => json_encode($body),
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( $options['notify_woosms_api_user_name'] . ':' . $options['notify_woosms_api_password'] ),
'Content-Type' => 'application/json',
),
) );
}
return false;
}