-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·196 lines (181 loc) · 7.09 KB
/
index.html
File metadata and controls
executable file
·196 lines (181 loc) · 7.09 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo JSSDK for RingCentral</title>
</head>
<body>
<div>
AppKey:<input type="text" id="appkey" value=""/>
</div>
<div>
App Secret: <input type="text" id="appSecret" value=""/>
</div>
<div>
UserID:<input type="text" id="userid" value=""/>
</div>
<div>
Extension:<input type="text" id="extension" value=""/>
</div>
<div>
Password:<input type="password" id="password" value=""/>
</div>
<div>
<input type = "button" value="Authorize" onclick="rcm.authorizeFields();"/>
</div>
<div>
<input type = "button" value="User Information" onclick="rcm.rch.get_info();">
</div>
<div>
<p id="result" style="align-self: center"></p>
</div>
<div>
From number:<input type="text" id="fromnumber" value=""/>
to Number : <input type="text" id="tonumber" value=""/>
message : <input type="text" id="textmessage" value="Hi This is test message"/>
<input type = "button" value="sendSMS" onclick="rcm.rch.send_sms($('#fromnumber').val(),$('#tonumber').val(),$('#textmessage').val());"/>
</div>
<div>
From number:<input type="text" id="from" value=""/>
<input type = "button" value="ringout" onclick="rcm.rch.ring_out($('#from').val(),$('#tonumber').val());"/>
</div>
<div>
<input type = "button" value="call logs" onclick="rcm.rch.call_log();"/>
<p id="call-logs" style="align-self: center"></p>
</div>
<div>
<input type = "button" value="presence check" onclick="rcm.rch.presence();"/>
<p id="presence" style="align-self: center"></p>
</div>
<div>
<input type = "button" value="message-store" onclick="rcm.rch.messagestore();"/>
<p id="message-store" style="align-self: center"></p>
</div>
</body>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
<script src="./bower_components/es6-promise-polyfill/promise.js"></script>
<script src="./bower_components/cryptojslib/rollups/aes.js"></script>
<script src="./bower_components/cryptojslib/rollups/sha256.js"></script>
<script src="./bower_components/cryptojslib/components/mode-ecb.js"></script>
<script src="./bower_components/pubnub/web/pubnub.js"></script>
<script src="./bower_components/rcsdk/build/rc-sdk.js"></script>
<script>
function rcManager(appKeyField,appSecretField,usernameField,extensionField,passwordField) {
var t=this;
t.appKeyField = appKeyField;
t.appSecretField = appSecretField;
t.usernameField = usernameField;
t.extensionField = extensionField;
t.passwordField = passwordField;
t.serverUrl = 'https://platform.devtest.ringcentral.com';
t.rcsdk = '';
t.rch = '';
t.authorizeFields = function() {
t.authorizeFull(
$(t.appKeyField).val(),
$(t.appSecretField).val(),
$(t.usernameField).val(),
$(t.extensionField).val(),
$(t.passwordField).val()
);
}
t.authorizeFull = function(appKey,appSecret,username,extension,password) {
t.loadRcsdk(appKey,appSecret);
t.authorize(username,extension,password);
}
t.loadRcsdk = function(appKey,appSecret) {
t.rcsdk = new RCSDK({
server: t.serverUrl,
appKey: appKey,
appSecret: appSecret
});
}
t.authorize = function(username,extension,password) {
p = t.rcsdk.getPlatform();
p.authorize({
username: username, // phone number in full format
extension: extension, // leave blank if direct number is used
password: password
}).then(function(response) {
// your code here
alert('success: ');
}).catch(function(e) {
alert('ERR ' + e.message || 'Server cannot authorize user');
});
t.rch = new rcHelper(p);
}
}
function rcHelper(platform) {
var t=this;
t.platform = platform;
t.send_sms = function(from,to,text) {
t.platform.post('/account/~/extension/~/sms', {
body: {
from: {phoneNumber:from}, // Your sms-enabled phone number
to: [
{phoneNumber:to} // Second party's phone number
],
text: text
}
}).then(function(response) {
alert('Success: ' + response.data.id);
}).catch(function(e) {
alert('Error: ' + e.message);
});
}
t.ring_out = function(from,to) {
this.platform.post('/account/~/extension/~/ringout', {
body: {
from: {phoneNumber:from}, // Your sms-enabled phone number
to: {phoneNumber:to}, // Second party's phone number
playPrompt: true
}
}).then(function(response) {
//alert('Success: ' + response.data.id);
}).catch(function(e) {
alert('Error: ' + e.message);
});
}
t.call_log = function() {
t.platform.get('/account/~/extension/~/call-log').then(function(response) {
alert('Success: ' + response.data.uri.toString());
var txt=JSON.stringify(response.data, null, 2);
document.getElementById("call-logs").innerHTML=txt;
}).catch(function(e) {
alert('Error: ' + e.message);
});
}
t.presence = function() {
t.platform.get('/account/~/extension/~/presence').then(function(response) {
alert('Success: ' + response.data.uri.toString());
var txt=JSON.stringify(response.data, null, 2);
document.getElementById("presence").innerHTML=txt;
}).catch(function(e) {
alert('Error: ' + e.message);
});
}
t.get_info = function() {
t.platform.get('/account/~/').then(function(response) {
alert('Success: ' + response.data.uri.toString());
var txt=JSON.stringify(response.data, null, 2);
document.getElementById("result").innerHTML=txt;
}).catch(function(e) {
alert('Error: ' + e.message);
});
}
t.messagestore= function() {
t.platform.get('/account/~/extension/~/message-store').then(function(response) {
alert('Success: ' + response.data.uri.toString());
var txt=JSON.stringify(response.data, null, 2);
document.getElementById("message-store").innerHTML=txt;
}).catch(function(e) {
alert('Error: ' + e.message);
});
}
}
rcm = new rcManager('#appkey','#appSecret','#userid','#extension','#password');
</script>
</html>