Skip to content

Instantly share code, notes, and snippets.

@anvyst
Last active December 11, 2015 10:08
Show Gist options
  • Save anvyst/4584705 to your computer and use it in GitHub Desktop.
Save anvyst/4584705 to your computer and use it in GitHub Desktop.
<?php
/* Custom API function to extract all products configoptions from tblproducts */
if( preg_match('/^\d+$/', $_POST['pid']) ) {
$resource_id = mysql_query("SELECT * FROM tblproducts WHERE id='{$_POST['pid']}'");
$rows = mysql_num_rows($resource_id);
$xml = array();
$xml[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$xml[] = "<whmcsapi version=\"5.1.3\">\n";
$xml[] = "<action>getproductconfigurations</action>\n";
if( $rows !== 0) {
$xml[] = "<result>success</result>\n";
$xml[] = "<totalresults>".$amount."</totalresults>\n";
$xml[] = "<products>";
while( $row = mysql_fetch_assoc($resource_id) ) {
$xml[] = "<id>{$row['id']}</id>";
$xml[] = "<configoption1>{$row['configoption1']}</configoption1>";
//and all the stuff you want to get from tblproducts records
}
$xml[] = "</products>";
} else {
$xml[] = "<result>error</result>";
$xml[] = "<message>Couldn't find product by {$_POST['pid']}</message>";
}
$xml[] = "</whmcsapi>";
echo join("\n", $xml);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment