Subversion Repositories oidplus

Rev

Rev 329 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
329 daniel-mar 1
<?php
2
 
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)
5
 
6
$request = array(
7
        "plugin" => "1.3.6.1.4.1.37476.2.5.2.4.1.0", // OID of plugin "publicPages/000_objects"
8
        "action" => "Insert",
9
        "parent" => "oid:2.999",
10
        "id" => 123,
11
        "ra_email" => "test@example.com",
12
        "comment" => "",
13
        "asn1ids" => "aaa,bbb,ccc",
14
        "iris" => "",
15
        "confidential" => 0,
16
        "weid" => "",
424 daniel-mar 17
        "batch_login_username" => "<username>",
18
        "batch_login_password" => "<password>",
19
        "batch_ajax_unlock_key" => "<unlock key>"
329 daniel-mar 20
);
21
 
22
$ch = curl_init();
424 daniel-mar 23
curl_setopt($ch, CURLOPT_URL, '<url>');
329 daniel-mar 24
curl_setopt($ch, CURLOPT_POST, 1);
25
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request));
26
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
27
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
28
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
29
if (!($res = @curl_exec($ch))) {
30
        die("Calling AJAX.PHP failed: " . curl_error($ch));
31
}
32
curl_close($ch);
33
 
34
$json = json_decode($res, true);
35
 
36
if (!$json) {
37
        die("Invalid JSON data $res");
38
}
39
 
40
if (isset($json['error'])) {
41
        die($json['error']);
42
} else if ($json['status'] == 0/*OK*/) {
43
        die("Insert OK");
44
} else if ($json['status'] == 1/*RaNotExisting*/) {
45
        die("Insert OK");
46
} else if ($json['status'] == 2/*RaNotExistingNoInvitation*/) {
47
        die("Insert OK");
48
} else {
49
        die("Error ".print_r($json,true));
50
}
51
 
52
?>