Differences

This shows you the differences between two versions of the page.

Link to this comparison view

userspace:php_json-rpc [2014/02/10 11:54] (current)
tobias created
Line 1: Line 1:
 +This is an example for creating new OPSI Clients and setting ProductActionRequest'​s via PHP.
  
 +You need the jsonRPCClient.php from [[http://​jsonrpcphp.org/​]] ​
 +<​code>​
 +
 +<?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;
 +                }
 +            }
 +           
 +        ​
 +        ​
 +        ​
 + 
 + 
 +?>
 +
 +</​code>​

QR Code
QR Code userspace:php_json-rpc (generated for current page)