This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sms.php
162 lines (137 loc) · 3.96 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
function sendSms($number, $message) {
// $authKey = "209549A6j7ZUX5I8By5ace616c"; // Bibek Singh ko
$authKey = "214511AjSNk4gz5zj5af2336e"; // Prashant Shahi ko
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://api.msg91.com/api/sendhttp.php?sender=AgMrkt&route=4&mobiles=".$number."&authkey=".$authKey."&encrypt=&country=91&message=".urlencode($message),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #:" . $err;
} else {
return $response;
}
}
function sendOtp($number,$user,$x = '') {
$authKey = "214511AjSNk4gz5zj5af2336e";
$message = "Your verification code is ##OTP##.\r\n OR go to www.AgMarket.in/otp-verify.php?u=".$user."&p=".$number."&otp=##OTP##.\r\nIt will be valid for 24 hours.";
if(isset($x) && !empty($x)) {
if($x == "forgot") {
$message = "Your verification code is ##OTP##.\r\n OR go to www.AgMarket.in/iforgot.php?u=".$user."&p=".$number."&otp=##OTP##.\r\nIt will be valid for 24 hours.";
}
}
/*
{
"message": "38656c766a45373236333334",
"type": "success"
}
{
"message": "38656c76745a313333383333",
"type": "success"
}
{
"message": "Please Enter valid mobile no",
"type": "error"
}
*/
// ###OTP###
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://control.msg91.com/api/sendotp.php?otp_length=7&authkey=".$authKey."&message=".urlencode($message)."&sender=AgMrkt&mobile=".$number,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "",
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #:" . $err;
} else {
return $response;
}
}
function resendOtp($number, $retrytype) {
$authKey = "214511AjSNk4gz5zj5af2336e";
/*
http://control.msg91.com/api/retryotp.php?authkey=214511AjSNk4gz5zj5af2336e&mobile=8880517895&retrytype=text
{
"type": "error"
}
*/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://control.msg91.com/api/retryotp.php?authkey=".$authKey."&mobile=".$number."&retrytype=".$retrytype,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "",
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_HTTPHEADER => array(
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #:" . $err;
} else {
return $response;
}
}
function verifyOtp($number, $otp) {
$authKey = "214511AjSNk4gz5zj5af2336e";
/*
{
"message": "otp_verified",
"type": "success"
}
*/
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://control.msg91.com/api/verifyRequestOTP.php?authkey=".$authKey."&mobile=".$number."&otp=".$otp,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "",
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_HTTPHEADER => array(
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
return "cURL Error #:" . $err;
} else {
return $response;
}
}
?>