Rev 568 | 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" => "", |
||
568 | daniel-mar | 17 | "OIDPLUS_AUTH_JWT" => "<token>" |
329 | daniel-mar | 18 | ); |
19 | |||
20 | $ch = curl_init(); |
||
424 | daniel-mar | 21 | curl_setopt($ch, CURLOPT_URL, '<url>'); |
329 | daniel-mar | 22 | curl_setopt($ch, CURLOPT_POST, 1); |
23 | curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request)); |
||
24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||
25 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
||
26 | curl_setopt($ch, CURLOPT_AUTOREFERER, true); |
||
27 | if (!($res = @curl_exec($ch))) { |
||
28 | die("Calling AJAX.PHP failed: " . curl_error($ch)); |
||
29 | } |
||
30 | curl_close($ch); |
||
31 | |||
32 | $json = json_decode($res, true); |
||
33 | |||
34 | if (!$json) { |
||
35 | die("Invalid JSON data $res"); |
||
36 | } |
||
37 | |||
38 | if (isset($json['error'])) { |
||
569 | daniel-mar | 39 | die($json['error']."\n"); |
329 | daniel-mar | 40 | } else if ($json['status'] == 0/*OK*/) { |
569 | daniel-mar | 41 | die("Insert OK\n"); |
329 | daniel-mar | 42 | } else if ($json['status'] == 1/*RaNotExisting*/) { |
569 | daniel-mar | 43 | die("Insert OK\n"); |
329 | daniel-mar | 44 | } else if ($json['status'] == 2/*RaNotExistingNoInvitation*/) { |
569 | daniel-mar | 45 | die("Insert OK\n"); |
329 | daniel-mar | 46 | } else { |
569 | daniel-mar | 47 | die("Error ".print_r($json,true)."\n"); |
329 | daniel-mar | 48 | } |
49 | |||
568 | daniel-mar | 50 | ?> |