Subversion Repositories oidplus

Rev

Rev 635 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  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" => "",
  17.         "OIDPLUS_AUTH_JWT" => "<token>"
  18. );
  19.  
  20. $ch = curl_init();
  21. curl_setopt($ch, CURLOPT_URL, '<url>');
  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'])) {
  39.         die($json['error']."\n");
  40. } else if ($json['status'] >= 0) {
  41.         die("Insert OK\n");
  42. } else {
  43.         die("Error ".print_r($json,true)."\n");
  44. }
  45.  
  46. ?>
  47.