User Tools

Site Tools


userspace:php_json-rpc

This is an example for creating new OPSI Clients and setting ProductActionRequest's via PHP.

You need the jsonRPCClient.php from http://jsonrpcphp.org/

<?php
require_once ('jsonRPCClient.php');
$check = @fopen('https://administrator:<password>@<opsiserver>:4447/rpc', "r");
$rpc = @new jsonRPCClient('https://administrator:<password>@<opsiserver>:4447/rpc', false, true);
 
if($rpc) {
                try {
              
                    $check = $rpc->authenticated();
                    if(!$check) {
                        $loginerror=true;
                    }
                   
                    else{
                        $info = $rpc->getOpsiInformation_hash();
                        $newclient = $rpc->createClient('<hostname>','<domain>','<description>','<note>','<inventory_number>', '<mac_address>');
                        $SetOS = $rpc->setProductActionRequest('win7', '<client fqdn>','setup');
                        $SetSoftware = $rpc->setProductActionRequest('<productID>', '<client fqdn>','setup');
              
                      
                      }
                } catch (Exception $e) {
                    $loginerror = true;
                }
            }
           
        
        
        
 
 
?>
userspace/php_json-rpc.txt · Last modified: 2021/08/23 08:37 (external edit)