-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_zoom_list.php
57 lines (41 loc) · 1.49 KB
/
get_zoom_list.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
<?php
$q = $_REQUEST['term'];
// TelecomsXChange Buyer Username, get one at www.telecomsxchange.com/buyerjoin
$api_login ="ENTER YOUR BUYER USERNAME HERE";
//API key
$api_key = "ENTER YOUR API KEY";
// initialising CURL
$ch = curl_init();
//controller is a script name, so in case lookup.php controller is lookup
$controller = "get_zoom_list";
//unix timestamp to ensure that signature will be valid temporary
$ts = time();
//compose signature concatenating controller api_key api_login and unix timestamp
$signature = hash( 'sha256', $controller . $api_key . $api_login . $ts);
$params = array(
'ts' => $ts, //provide TS
'q' => $q,
'api_login' => $api_login,
'signature' => $signature,
'webapi' => 1,
//...
);
//query against api. URL
//debug CURL?
//curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_URL,"https://members.telecomsxchange.com/scripts/autocomplete/$controller.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
//analyze JSON output
//echo "server_output:$server_output";
$response = json_decode($server_output, JSON_OBJECT_AS_ARRAY);
//print_r($response);
if($response['status'] == 'success' ) {
header('Content-Type: application/json');
echo json_encode($response['entries']);
}
?>