[
'method' => 'post',
'content' => $data,
'header' => $header
]
];
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if(!$fp){
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
fclose($fp);
if($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
}
?>
JSONRPC Zabbix API
'2.0',
'method' => 'user.login',
'params' => ['user'=>$user, 'password'=>$pswd],
'id'=> 1
];
$data = json_encode($data);
$response = do_post_request($url, $data);
$json_decoded = json_decode($response, true);
$auth = $json_decoded['result'];
?>
AUTH
'2.0',
'method' => $_REQUEST['apimethod'],
'params' => json_decode($_REQUEST['apiparams'], true),
'auth' => $auth,
'id'=> 2
];
$data = json_encode($data);
$response = do_post_request($url, $data);
?>
API call