-
Notifications
You must be signed in to change notification settings - Fork 1
/
directory_domain_user_create.php
64 lines (56 loc) · 1.57 KB
/
directory_domain_user_create.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
<?php
/*
* directory domain user create
*/
include_once 'setting.inc.php';
require_once PEST_PATH.'pest/PestJSON.php';
$options['server'] = 'http://' . SERVER;
$options['request'] = 'POST';
$base_url = $options['server'] .'/SAFe/sng_rest/api/';
$method_name = 'create';
$module_name = 'directory';
$obj_type = 'domain';
$obj_name = 'test5.com';
$sub_obj_type = 'user';
$sub_obj_name = 'hongke1';
$request_uri = $method_name .'/'. $module_name .'/'. $obj_type .'/'. $obj_name .'/'. $sub_obj_type .'/'. $sub_obj_name ;
$json_data ='
{
"password": "1111",
"effective_caller_id_name": "1111",
"effective_caller_id_number": "1111",
"call-routing": "default"
}';
$data = json_decode($json_data);
try {
//API_KEY defined in 'setting.inc.php' send api key in header
//$header_array[]="X-API-KEY:C2FF69E5B86551C8062F9B56E1065370"
//$header_array[]="Content-Type: application/json" auto set by PestJSON
if(defined('API_KEY'))
{
$header_array[] = 'X-API-KEY:'.API_KEY;
}else{
$header_array = null;
}
$pest = new PestJSON($base_url);
$status = $pest->post($request_uri, $data, $header_array);
} catch(Exception $e) {
$status = json_decode($e->getMessage(), true);
}
$rc = $pest->lastStatus();
print('URL : ' . $base_url.$request_uri.PHP_EOL);
print('Output : ' . json_encode($status) .PHP_EOL);
print('Status : ' . $rc.PHP_EOL);
/*
* Output sample
{
"status": true,
"method": "create",
"module": "directory",
"type": "domain",
"name": "test5.com",
"child_type": "user",
"child_name": "hongke1"
}Status: 200
*/
?>