I'm developing a hook but can't seem to get API1 calls working
The hook has been registered via manage_hook and runs (I've enabled debughooks (level 3) and checked the error_log - the correct hook is being called and the correct data is being sent)
However, there aren't many docs on how to do anything from within the hook. I'm attempting to use XML-API1 (with xmlapi.php included) - see below:
How can I:
a) Output data from the hook function so I can debug? (i.e. where does $xmlapi sent its output to? Where do hook 'prints' go to?
b) Get the API calls to work?
Many thanks!
Paul
The hook has been registered via manage_hook and runs (I've enabled debughooks (level 3) and checked the error_log - the correct hook is being called and the correct data is being sent)
However, there aren't many docs on how to do anything from within the hook. I'm attempting to use XML-API1 (with xmlapi.php included) - see below:
PHP:
function hook() {
$stdin_fh = fopen('php://stdin', 'r');
while ($line = fgets( $stdin_fh )) {
$raw_data .= $line;
}
fclose($stdin_fh);
$hookdata = json_decode($raw_data, true);
$context = $hookdata['context'];
$data = $hookdata['data'];
if($data['plan'] == "Joomla"){
// Connect to API1
$ip = "127.0.0.1";
$root_pass = "XXXXXXXX";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth("root", $root_pass);
// Create the database
$account = $data['user'];
$database = $data['user']."_joomla";
$xmlapi->set_debug(1);
print $xmlapi->api1_query($account, "Mysql", "adddb", array($database));
// Create the database user
$dbUsername = $data['user']."_sys";
$dbPassword = $data['pass'];
echo $xmlapi->api1_query($account, "Mysql", "adduser", array($dbUsername, dbPassword));
// Give new user permissions for new db
$dbPermissions = "all";
echo $xmlapi->api1_query($account, "Mysql", "adduserdb", array($database, $dbUsername, $dbPermissions));
// Export Joomla from SVN
//shell_exec("svn export https://github.com/joomla/joomla-cms/tags/3.2.0 /home/".$data['user']."/public_html/ --force");
//shell_exec("chown -R ".$data['user'].":".$data['user']." /home/".$data['user']."/public_html/*");
return 1, "Created ".$database." DB, created ".$dbUsername." user (password '".$dbPassword."')";
}
return 1, "Joomla plan not selected";
}
a) Output data from the hook function so I can debug? (i.e. where does $xmlapi sent its output to? Where do hook 'prints' go to?
b) Get the API calls to work?
Many thanks!
Paul