· 6 years ago · Apr 17, 2020, 05:12 PM
1<?php
2$json_url = "http://api.ebulksms.com:8080/sendsms.json";
3$xml_url = "http://api.ebulksms.com:8080/sendsms.xml";
4$http_get_url = "http://api.ebulksms.com:8080/sendsms";
5$username = '';
6$apikey = '';
7
8if (isset($_POST['button'])) {
9 $username = $_POST['username'];
10 $apikey = $_POST['apikey'];
11 $sendername = substr($_POST['sender_name'], 0, 11);
12 $recipients = $_POST['telephone'];
13 $message = $_POST['message'];
14 $flash = 0;
15 if (get_magic_quotes_gpc()) {
16 $message = stripslashes($_POST['message']);
17 }
18 $message = substr($_POST['message'], 0, 160);
19
20
21
22 result = doPostRequest($http_get_url, $username, $apikey, $flash, $sendername, $message, $recipients);
23}
24
25
26
27//Function to connect to SMS sending server using HTTP POST
28function doPostRequest($http_get_url, $arr_params, $headers = array('Content-Type: application/x-www-form-urlencoded')) {
29 $response = array();
30 $final_url_data = $arr_params;
31 if (is_array($arr_params)) {
32 $final_url_data = http_build_query($arr_params, '', '&');
33 }
34 $ch = curl_init();
35 curl_setopt($ch, CURLOPT_URL, "{$url}?{$query_str}");
36 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
37 $output = curl_exec($ch);
38 curl_close($ch);
39 return $output;
40}
41
42?>
43
44<!DOCTYPE html>
45<html lang="en">
46 <head>
47 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
48 <title>EbulkSMS Send SMS API Sample</title>
49 </head>
50
51 <body>
52 <h2 style="text-align: center">Ebulk SMS Integration Sample Code</h2>
53 <div style="border: 1px solid #333; padding: 5px 10px; width: 40%; margin: 0 auto">
54 <form id="form1" name="form1" method="post" action="">
55
56 <?php
57 if (!empty($_POST)) {
58 if ($result == 'SUCCESS') {?>
59 <p style="border: 1px dotted #333; background: #33ff33; padding: 5px;">Message sent</p>
60 <?php
61 }
62 else {?>
63 <p style="border: 1px dotted #333; background: #FFDACC; padding: 5px;">Message not sent - <?php echo $result;?></p>
64 <?php
65 }
66 }
67 ?>
68
69 <p>
70 <label>Username:
71 <input name="username" type="text" id="username"/>
72 </label>
73 </p>
74 <p>
75 <label>API Key:
76 <input name="apikey" type="password" id="passwd" />
77 </label>
78 </p>
79 <p>
80 <label>Sender name:
81 <input name="sender_name" type="text" id="name" value="Integration" />
82 </label>
83 </p>
84 <p>
85 <label>Recipients
86 <textarea name="telephone" id="telephone" cols="45" rows="2"></textarea>
87 </label>
88 </p>
89 <p>
90 <label>Message
91 <textarea name="message" id="message" cols="45" rows="5"></textarea>
92 </label>
93 </p>
94 <p>
95 <label>
96 <input type="submit" name="button" id="button" value="Submit" />
97 </label>
98 <label>
99 <input type="reset" name="button2" id="button2" value="Reset" />
100 </label>
101 </p>
102 </form>
103 </div>
104 </body>
105</html>