Subversion Repositories oidplus

Rev

Rev 635 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 635 Rev 1292
1
<?php
1
<?php
2
 
2
 
3
// This is an example script that shows how you can insert an OID
3
// This is an example script that shows how you can insert an OID
4
// (in this example "2.999.123") using an authenticated AJAX query ("RPC"-like)
4
// (in this example "2.999.123") using an authenticated AJAX query ("RPC"-like)
5
 
5
 
6
$request = array(
6
$request = array(
7
        "plugin" => "1.3.6.1.4.1.37476.2.5.2.4.1.0", // OID of plugin "publicPages/000_objects"
7
        "plugin" => "1.3.6.1.4.1.37476.2.5.2.4.1.0", // OID of plugin "publicPages/000_objects"
8
        "action" => "Insert",
8
        "action" => "Insert",
9
        "parent" => "oid:2.999",
9
        "parent" => "oid:2.999",
10
        "id" => 123,
10
        "id" => 123,
11
        "ra_email" => "test@example.com",
11
        "ra_email" => "test@example.com",
12
        "comment" => "",
12
        "comment" => "",
13
        "asn1ids" => "aaa,bbb,ccc",
13
        "asn1ids" => "aaa,bbb,ccc",
14
        "iris" => "",
14
        "iris" => "",
15
        "confidential" => 0,
15
        "confidential" => 0,
16
        "weid" => "",
16
        "weid" => "",
17
        "OIDPLUS_AUTH_JWT" => "<token>"
17
        "OIDPLUS_AUTH_JWT" => "<token>"
18
);
18
);
19
 
19
 
20
$ch = curl_init();
20
$ch = curl_init();
21
curl_setopt($ch, CURLOPT_URL, '<url>');
21
curl_setopt($ch, CURLOPT_URL, '<url>');
22
curl_setopt($ch, CURLOPT_POST, 1);
22
curl_setopt($ch, CURLOPT_POST, 1);
23
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request));
23
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request));
24
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
24
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
25
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
25
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
26
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
26
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
27
if (!($res = @curl_exec($ch))) {
27
if (!($res = @curl_exec($ch))) {
28
        die("Calling AJAX.PHP failed: " . curl_error($ch));
28
        die("Calling AJAX.PHP failed: " . curl_error($ch));
29
}
29
}
30
curl_close($ch);
30
curl_close($ch);
31
 
31
 
32
$json = json_decode($res, true);
32
$json = json_decode($res, true);
33
 
33
 
34
if (!$json) {
34
if (!$json) {
35
        die("Invalid JSON data $res");
35
        die("Invalid JSON data $res");
36
}
36
}
37
 
37
 
38
if (isset($json['error'])) {
38
if (isset($json['error'])) {
39
        die($json['error']."\n");
39
        die($json['error']."\n");
40
} else if ($json['status'] == 0/*OK*/) {
40
} else if ($json['status'] >= 0) {
41
        die("Insert OK\n");
-
 
42
} else if ($json['status'] == 1/*RaNotExisting*/) {
-
 
43
        die("Insert OK\n");
-
 
44
} else if ($json['status'] == 2/*RaNotExistingNoInvitation*/) {
-
 
45
        die("Insert OK\n");
41
        die("Insert OK\n");
46
} else {
42
} else {
47
        die("Error ".print_r($json,true)."\n");
43
        die("Error ".print_r($json,true)."\n");
48
}
44
}
49
 
45
 
50
?>
46
?>
51
 
47